best fichinter method

This commit is contained in:
Rodolphe Quiedeville
2002-12-22 20:04:24 +00:00
parent f87b891838
commit 5e577dea79
5 changed files with 238 additions and 122 deletions

View File

@@ -70,7 +70,10 @@ class Don
print "<li>" . $this->errorstr[$i]; print "<li>" . $this->errorstr[$i];
} }
} }
/*
*
*
*/
Function check($minimum=0) Function check($minimum=0)
{ {
$err = 0; $err = 0;

View File

@@ -1,8 +1,5 @@
<?PHP <?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -18,6 +15,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Id$
* $Source$
*
*/ */
class Fichinter { class Fichinter {
@@ -29,16 +29,19 @@ class Fichinter {
var $date; var $date;
var $duree; var $duree;
var $note; var $note;
var $projet_id;
Function Fichinter($DB, $soc_idp="")
Function Fichinter($DB, $soc_idp="") { {
$this->db = $DB ; $this->db = $DB ;
$this->socidp = $soc_idp; $this->socidp = $soc_idp;
$this->products = array(); $this->products = array();
} }
Function add_product($idproduct) { Function add_product($idproduct)
if ($idproduct > 0) { {
if ($idproduct > 0)
{
$i = sizeof($this->products); $i = sizeof($this->products);
$this->products[$i] = $idproduct; $this->products[$i] = $idproduct;
} }
@@ -48,17 +51,19 @@ class Fichinter {
* *
* *
*/ */
Function create() { Function create()
{
/* /*
* Insertion dans la base * Insertion dans la base
*/ */
if (!strlen($this->duree)) { $this->duree = 0; } if (!strlen($this->duree)) { $this->duree = 0; }
$sql = "INSERT INTO llx_fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree) "; $sql = "INSERT INTO llx_fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree, fk_projet) ";
$sql .= " VALUES ($this->socidp, $this->date, now(), '$this->ref', $this->author, '$this->note', $this->duree)"; $sql .= " VALUES ($this->socidp, $this->date, now(), '$this->ref', $this->author, '$this->note', $this->duree, $this->projet_id)";
$sqlok = 0; $sqlok = 0;
if (! $this->db->query($sql) ) { if (! $this->db->query($sql) )
{
print $this->db->error() . '<b><br>'.$sql; print $this->db->error() . '<b><br>'.$sql;
} }
return $this->db->last_insert_id(); return $this->db->last_insert_id();
@@ -68,7 +73,8 @@ class Fichinter {
* *
* *
*/ */
Function update($id) { Function update($id)
{
/* /*
* Insertion dans la base * Insertion dans la base
*/ */
@@ -76,9 +82,11 @@ class Fichinter {
$sql .= " datei = $this->date,"; $sql .= " datei = $this->date,";
$sql .= " note = '$this->note',"; $sql .= " note = '$this->note',";
$sql .= " duree = $this->duree"; $sql .= " duree = $this->duree";
$sql .= ", fk_projet = $this->projet_id";
$sql .= " WHERE rowid = $id"; $sql .= " WHERE rowid = $id";
if (! $this->db->query($sql) ) { if (! $this->db->query($sql) )
{
print $this->db->error() . '<b><br>'.$sql; print $this->db->error() . '<b><br>'.$sql;
} }
@@ -89,12 +97,15 @@ class Fichinter {
* *
* *
*/ */
Function fetch($rowid) { Function fetch($rowid)
{
$sql = "SELECT ref,note,fk_statut,duree,".$this->db->pdate(datei)."as di FROM llx_fichinter WHERE rowid=$rowid;"; $sql = "SELECT ref,note,fk_soc,fk_statut,duree,".$this->db->pdate(datei)."as di, fk_projet FROM llx_fichinter WHERE rowid=$rowid;";
if ($this->db->query($sql) ) { if ($this->db->query($sql) )
if ($this->db->num_rows()) { {
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object(0); $obj = $this->db->fetch_object(0);
$this->id = $rowid; $this->id = $rowid;
@@ -102,11 +113,15 @@ class Fichinter {
$this->duree = $obj->duree; $this->duree = $obj->duree;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->note = $obj->note; $this->note = $obj->note;
$this->societe_id = $obj->fk_soc;
$this->projet_id = $obj->fk_projet;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->db->free(); $this->db->free();
} }
} else { }
else
{
print $this->db->error(); print $this->db->error();
} }
} }

View File

@@ -82,6 +82,42 @@ class Form {
} }
/* /*
*
*
*/
Function select_array($name, $array, $id='')
{
print '<select name="'.$name.'">';
$i = 0;
if (strlen($id))
{
reset ($array);
while (list($key, $value) = each ($array))
{
print "<option value=\"$key\" ";
if ($id == $key)
{
print "SELECTED";
}
print ">$value</option>\n";
}
}
else
{
while (list($key, $value) = each ($array) )
{
print "<option value=\"$key\" ";
print ">$value</option>\n";
}
}
print "</select>";
}
/*
* Renvoie la cha<68>ne de caract<63>re d<>crivant l'erreur * Renvoie la cha<68>ne de caract<63>re d<>crivant l'erreur
* *
* *

View File

@@ -284,8 +284,13 @@ function print_oui_non($value)
* *
* *
*/ */
function print_date_select() function print_date_select($set_time='')
{ {
if (! isset($set_time))
{
$set_time = time();
}
$strmonth[1] = "Janvier"; $strmonth[1] = "Janvier";
$strmonth[2] = "F&eacute;vrier"; $strmonth[2] = "F&eacute;vrier";
$strmonth[3] = "Mars"; $strmonth[3] = "Mars";
@@ -300,8 +305,8 @@ function print_date_select()
$strmonth[12] = "D&eacute;cembre"; $strmonth[12] = "D&eacute;cembre";
$smonth = 1; $smonth = 1;
$syear = date("Y", time()); $syear = date("Y", $set_time);
$cday = date("d", time()); $cday = date("d", $set_time);
print "<select name=\"reday\">"; print "<select name=\"reday\">";
@@ -317,9 +322,9 @@ function print_date_select()
} }
} }
print "</select>"; print "</select>";
$cmonth = date("n", time());
$cmonth = date("n", $set_time);
print "<select name=\"remonth\">"; print "<select name=\"remonth\">";
for ($month = $smonth ; $month < $smonth + 12 ; $month++) for ($month = $smonth ; $month < $smonth + 12 ; $month++)
{ {
@@ -425,7 +430,8 @@ function gljftime($format,$timestamp) {
} }
function gljPrintTitle($title, $ispage, $page=0, $parm=0) { function gljPrintTitle($title, $ispage, $page=0, $parm=0)
{
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@@ -435,11 +441,13 @@ function gljPrintTitle($title, $ispage, $page=0, $parm=0) {
print "<b>$title</b></td><td align=\"right\">$basec <b>Page $pagenext</b>"; print "<b>$title</b></td><td align=\"right\">$basec <b>Page $pagenext</b>";
print "</td>"; print "</td>";
if ($ispage) { if ($ispage)
{
print "</tr>"; print "</tr>";
print "<tr><td>"; print "<tr><td>";
if ($page > 0) { if ($page > 0)
{
print "<A href=\"".$GLOBALS["PHP_SELF"]."?page=$pageprev&$parm\"><- ".$GLOBALS["_PAGE_PREV"]."</A>"; print "<A href=\"".$GLOBALS["PHP_SELF"]."?page=$pageprev&$parm\"><- ".$GLOBALS["_PAGE_PREV"]."</A>";
} }
print "</td>\n"; print "</td>\n";
@@ -448,18 +456,28 @@ function gljPrintTitle($title, $ispage, $page=0, $parm=0) {
print "</tr></table>"; print "</tr></table>";
}; };
/*
*
*
*/
function gljActiveSoc($db, $socidp)
{
function gljActiveSoc($db, $socidp) { if ($db)
{
if ($db) {
$sql = "UPDATE societe set datea = " . time() . " WHERE idp= " . $socidp ; $sql = "UPDATE societe set datea = " . time() . " WHERE idp= " . $socidp ;
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) { if (!$result)
{
return 1; return 1;
} }
return 0; return 0;
} }
} }
/*
*
*
*/
function gljChangeSocAlias($db, $socidp, $alias) { function gljChangeSocAlias($db, $socidp, $alias) {
if ($db) { if ($db) {

View File

@@ -1,8 +1,5 @@
<?PHP <?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -18,6 +15,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Id$
* $Source$
*
*/ */
@@ -78,15 +78,19 @@ class Project {
* *
* *
*/ */
Function get_propal_list() { Function get_propal_list()
{
$propales = array(); $propales = array();
$sql = "SELECT rowid FROM llx_propal WHERE fk_projet=$this->id;"; $sql = "SELECT rowid FROM llx_propal WHERE fk_projet=$this->id;";
if ($this->db->query($sql) ) { if ($this->db->query($sql) )
{
$nump = $this->db->num_rows(); $nump = $this->db->num_rows();
if ($nump) { if ($nump)
{
$i = 0; $i = 0;
while ($i < $nump) { while ($i < $nump)
{
$obj = $this->db->fetch_object($i); $obj = $this->db->fetch_object($i);
$propales[$i] = $obj->rowid; $propales[$i] = $obj->rowid;
@@ -99,11 +103,51 @@ class Project {
*/ */
return $propales; return $propales;
} }
} else { }
else
{
print $this->db->error() . '<br>' .$sql; print $this->db->error() . '<br>' .$sql;
} }
}
/*
*
*
*
*/
Function liste_array($id_societe='')
{
$projets = array();
$sql = "SELECT rowid, title FROM llx_projet";
if (isset($id_societe))
{
$sql .= " WHERE fk_soc = $id_societe";
}
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($i);
$projets[$obj->rowid] = $obj->title;
$i++;
}
}
return $projets;
}
else
{
print $this->db->error();
}
} }
} }
?> ?>