New: Ajout methode load_board sur chaque objet métier pour tableau de bord Dolibarr.

This commit is contained in:
Laurent Destailleur 2005-08-11 20:01:25 +00:00
parent e4c4058211
commit ec36e49fa2
3 changed files with 333 additions and 257 deletions

View File

@ -21,14 +21,16 @@
* *
*/ */
/*! \file htdocs/don.class.php /**
\file htdocs/don.class.php
\ingroup don \ingroup don
\brief Fichier de la classe des dons \brief Fichier de la classe des dons
\version $Revision$ \version $Revision$
*/ */
/*! \class Don /**
\class Don
\brief Classe permettant la gestion des dons \brief Classe permettant la gestion des dons
*/ */
@ -173,11 +175,12 @@ class Don
} }
/* /**
* \brief Création du don en base * \brief Création du don en base
* \param userid utilisateur qui crée le don * \param userid Objet utilisateur qui crée le don
* \return int id don crée si ok, <0 si ko
*/ */
function create($userid) function create($user)
{ {
$this->date = $this->db->idate($this->date); $this->date = $this->db->idate($this->date);
@ -192,10 +195,9 @@ class Don
{ {
$sql .= " $this->projetid,"; $sql .= " $this->projetid,";
} }
$sql .= " '$this->commentaire', $userid, '$this->date','$this->email')"; $sql .= " '$this->commentaire', ".$user->id.", '$this->date','$this->email')";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); return $this->db->last_insert_id(MAIN_DB_PREFIX."don");
@ -203,16 +205,16 @@ class Don
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return 0; return -1;
} }
} }
/* /**
* \brief Mise à jour du don * \brief Mise à jour du don
* \param userid utilisateur qui crée le don * \param user Objet utilisateur qui met à jour le don
* * \return int >0 si ok, <0 si ko
*/ */
function update($userid) function update($user)
{ {
$this->date = $this->db->idate($this->date); $this->date = $this->db->idate($this->date);
@ -237,7 +239,6 @@ class Don
$sql .= " WHERE rowid = $this->id"; $sql .= " WHERE rowid = $this->id";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
return 1; return 1;
@ -245,7 +246,7 @@ class Don
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return 0; return -1;
} }
} }
@ -266,13 +267,13 @@ class Don
} }
else else
{ {
return 0; return -1;
} }
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return 0; return -1;
} }
} }
@ -283,9 +284,11 @@ class Don
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = "SELECT d.rowid, ".$this->db->pdate("d.datedon")." as datedon, d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet"; $sql = "SELECT d.rowid, ".$this->db->pdate("d.datec")." as datec,";
$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."c_paiement as cp LEFT JOIN ".MAIN_DB_PREFIX."don_projet as p"; $sql.= " ".$this->db->pdate("d.datedon")." as datedon,";
$sql .= " ON p.rowid = d.fk_don_projet WHERE cp.id = d.fk_paiement AND d.rowid = $rowid"; $sql.= " d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."c_paiement as cp LEFT JOIN ".MAIN_DB_PREFIX."don_projet as p";
$sql.= " ON p.rowid = d.fk_don_projet WHERE cp.id = d.fk_paiement AND d.rowid = $rowid";
if ( $this->db->query( $sql) ) if ( $this->db->query( $sql) )
{ {
@ -295,6 +298,7 @@ class Don
$obj = $this->db->fetch_object(); $obj = $this->db->fetch_object();
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->datec = $obj->datec;
$this->date = $obj->datedon; $this->date = $obj->datedon;
$this->prenom = stripslashes($obj->prenom); $this->prenom = stripslashes($obj->prenom);
$this->nom = stripslashes($obj->nom); $this->nom = stripslashes($obj->nom);

View File

@ -1219,7 +1219,7 @@ class Facture
} }
/** /**
* \brief Renvoi le libellé court d'un statut donn * \brief Renvoi le libellé court d'un statut donné
* \param paye etat paye * \param paye etat paye
* \param statut id statut * \param statut id statut
* \param amount amount already payed * \param amount amount already payed
@ -1264,9 +1264,9 @@ class Facture
} }
} }
/* /**
* \brief Charge les informations d'ordre info dans l'objet facture * \brief Charge les informations d'ordre info dans l'objet facture
* \param id id de la facture a charger * \param id Id de la facture a charger
*/ */
function info($id) function info($id)
{ {
@ -1569,13 +1569,44 @@ class Facture
} }
} }
} }
/**
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
* \return int <0 si ko, >0 si ok
*/
function load_board()
{
global $conf;
$this->nbtodo=$this->nbtodolate=0;
$sql = "SELECT f.rowid,".$this->db->pdate("f.date_lim_reglement")." as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.paye=0 AND f.fk_statut = 1";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nbtodo++;
if ($obj->datefin < (time() - $conf->facture->client->warning_delay)) $this->nbtodolate++;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
} }
/** /**
\class FactureLigne \class FactureLigne
\brief Classe permettant la gestion des lignes de factures \brief Classe permettant la gestion des lignes de factures
*/ */
class FactureLigne class FactureLigne
@ -1590,6 +1621,7 @@ class FactureLigne
$this->db= $DB ; $this->db= $DB ;
} }
/** /**
* \brief Recupére l'objet ligne de facture * \brief Recupére l'objet ligne de facture
* \param rowid id de la ligne de facture * \param rowid id de la ligne de facture

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -62,6 +62,10 @@ class Propal
var $product=array(); var $product=array();
// Pour board
var $nbtodo;
var $nbtodolate;
/** /**
* \brief Constructeur * \brief Constructeur
@ -119,10 +123,9 @@ class Propal
* \param idproduct id du produit à ajouter * \param idproduct id du produit à ajouter
* \param qty quantité * \param qty quantité
* \param remise_percent remise effectuée sur le produit * \param remise_percent remise effectuée sur le produit
* \return int 0 en cas de succès * \return int >0 si ok, <0 si ko
* \see add_product * \see add_product
*/ */
function insert_product($idproduct, $qty, $remise_percent=0) function insert_product($idproduct, $qty, $remise_percent=0)
{ {
if ($this->statut == 0) if ($this->statut == 0)
@ -145,7 +148,6 @@ class Propal
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$this->update_price(); $this->update_price();
return 1; return 1;
} }
else else
@ -159,6 +161,7 @@ class Propal
} }
} }
} }
/** /**
* \brief Mise à jour d'une ligne de produit * \brief Mise à jour d'une ligne de produit
* \param id id de la ligne * \param id id de la ligne
@ -189,7 +192,6 @@ class Propal
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$this->update_price(); $this->update_price();
return 0; return 0;
} }
else else
@ -204,6 +206,7 @@ class Propal
return -2; return -2;
} }
} }
/** /**
* *
* *
@ -247,14 +250,12 @@ class Propal
} }
else else
{ {
print $this->db->error();
print "<br>".$sql;
return -2; return -2;
} }
} }
} }
/* /**
* *
* *
*/ */
@ -348,12 +349,12 @@ class Propal
} }
else else
{ {
//dolibarr_print_error($this->db); return -2;
} }
} }
else else
{ {
//dolibarr_print_error($this->db); return -1;
} }
return $this->id; return $this->id;
} }
@ -582,7 +583,6 @@ class Propal
} }
else else
{ {
//dolibarr_print_error($this->db);
return -1; return -1;
} }
} }
@ -1065,12 +1065,52 @@ class Propal
else return $this->labelstatut_short[$statut]; else return $this->labelstatut_short[$statut];
} }
/**
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
* \param mode opened pour propal à fermer, signed pour propale à facturer
* \return int <0 si ko, >0 si ok
*/
function load_board($mode)
{
global $conf;
$this->nbtodo=$this->nbtodolate=0;
$sql = "SELECT p.rowid,".$this->db->pdate("p.datec")." as datec,".$this->db->pdate("p.fin_validite")." as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
if ($mode == 'opened') $sql.= " WHERE p.fk_statut = 1";
if ($mode == 'signed') $sql.= " WHERE p.fk_statut = 2";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nbtodo++;
if ($obj->datefin < (time() - $conf->propal->cloture->warning_delay)) $this->nbtodolate++;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
} }
/**
\class PropalLigne
\brief Classe permettant la gestion des lignes de propales
*/
class PropaleLigne class PropaleLigne
{ {
function PropaleLigne() function PropaleLigne()
{ {
} }
} }
?> ?>