2
0
forked from Wavyzz/dolibarr

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,87 +29,102 @@ 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) { {
$i = sizeof($this->products); if ($idproduct > 0)
$this->products[$i] = $idproduct; {
$i = sizeof($this->products);
$this->products[$i] = $idproduct;
}
} }
}
/* /*
* *
* *
* *
*/ */
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();
}
/*
*
*
*
*/
Function update($id) {
/*
* Insertion dans la base
*/
$sql = "UPDATE llx_fichinter SET ";
$sql .= " datei = $this->date,";
$sql .= " note = '$this->note',";
$sql .= " duree = $this->duree";
$sql .= " WHERE rowid = $id";
if (! $this->db->query($sql) ) {
print $this->db->error() . '<b><br>'.$sql;
}
return 1;
}
/*
*
*
*
*/
Function fetch($rowid) {
$sql = "SELECT ref,note,fk_statut,duree,".$this->db->pdate(datei)."as di FROM llx_fichinter WHERE rowid=$rowid;";
if ($this->db->query($sql) ) {
if ($this->db->num_rows()) {
$obj = $this->db->fetch_object(0);
$this->id = $rowid;
$this->date = $obj->di;
$this->duree = $obj->duree;
$this->ref = $obj->ref;
$this->note = $obj->note;
$this->statut = $obj->fk_statut;
$this->db->free();
} }
} else { return $this->db->last_insert_id();
print $this->db->error(); }
} /*
} *
*
*
*/
Function update($id)
{
/*
* Insertion dans la base
*/
$sql = "UPDATE llx_fichinter SET ";
$sql .= " datei = $this->date,";
$sql .= " note = '$this->note',";
$sql .= " duree = $this->duree";
$sql .= ", fk_projet = $this->projet_id";
$sql .= " WHERE rowid = $id";
if (! $this->db->query($sql) )
{
print $this->db->error() . '<b><br>'.$sql;
}
return 1;
}
/*
*
*
*
*/
Function fetch($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->num_rows())
{
$obj = $this->db->fetch_object(0);
$this->id = $rowid;
$this->date = $obj->di;
$this->duree = $obj->duree;
$this->ref = $obj->ref;
$this->note = $obj->note;
$this->societe_id = $obj->fk_soc;
$this->projet_id = $obj->fk_projet;
$this->statut = $obj->fk_statut;
$this->db->free();
}
}
else
{
print $this->db->error();
}
}
/* /*
* *
* *

View File

@@ -30,7 +30,7 @@ class Form {
$this->db = $DB; $this->db = $DB;
return 1; return 1;
} }
/* /*
* *
* *
@@ -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,31 +441,43 @@ 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 align=\"right\"><A href=\"".$GLOBALS["PHP_SELF"]."?&page=$pagenext&$parm\">$_PAGE_NEXT -></A>\n";
} }
print "</td>\n";
print "<td align=\"right\"><A href=\"".$GLOBALS["PHP_SELF"]."?&page=$pagenext&$parm\">$_PAGE_NEXT -></A>\n";
}
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,32 +78,76 @@ class Project {
* *
* *
*/ */
Function get_propal_list() { Function get_propal_list()
$propales = array(); {
$sql = "SELECT rowid FROM llx_propal WHERE fk_projet=$this->id;"; $propales = array();
$sql = "SELECT rowid FROM llx_propal WHERE fk_projet=$this->id;";
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;
if ($this->db->query($sql) ) { $i++;
$nump = $this->db->num_rows(); }
if ($nump) { $this->db->free();
$i = 0; /*
while ($i < $nump) { * Retourne un tableau contenant la liste des propales associees
$obj = $this->db->fetch_object($i); */
return $propales;
$propales[$i] = $obj->rowid; }
$i++;
} }
$this->db->free(); else
/* {
* Retourne un tableau contenant la liste des propales associees print $this->db->error() . '<br>' .$sql;
*/ }
return $propales;
}
} else {
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();
}
}
} }
?> ?>