diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index ea5dcd7ec5de7f18f88ce15e968e445b88fab456..1def65faa587a5f2d4c9cd49a21bd3315eeb1087 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -1094,11 +1094,11 @@ class Contrat extends CommonObject /** - \brief Renvoie nom clicable (avec eventuellement le picto) - \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - \param maxlength Max length of ref - \return string Chaine avec URL - */ + * \brief Renvoie nom clicable (avec eventuellement le picto) + * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * \param maxlength Max length of ref + * \return string Chaine avec URL + */ function getNomUrl($withpicto=0,$maxlength=0) { global $langs; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index c9052da360273bfb114a67d63f22e3d331ffa281..50db3f1b21b1247d21d3803f2ac867d79743530a 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -27,6 +27,7 @@ require("./pre.inc.php"); require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); +require_once (DOL_DOCUMENT_ROOT."/product.class.php"); require_once (DOL_DOCUMENT_ROOT."/societe.class.php"); $langs->load("products"); @@ -72,7 +73,8 @@ llxHeader(); $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,"; $sql.= " s.rowid as socid, s.nom,"; -$sql.= " cd.rowid, cd.description, cd.statut, p.rowid as pid, p.label as label,"; +$sql.= " cd.rowid, cd.description, cd.statut,"; +$sql.= " p.rowid as pid, p.label as label, p.fk_product_type as ptype,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_ouverture_prevue,"; $sql.= " ".$db->pdate("cd.date_ouverture")." as date_ouverture,"; @@ -151,13 +153,13 @@ if ($resql) print '<td class="liste_titre">'; print '<input type="hidden" name="filter" value="'.$filter.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">'; - print '<input type="text" class="flat" size="3" name="search_contract" value="'.stripslashes($search_contract).'">'; + print '<input type="text" class="flat" size="3" name="search_contract" value="'.$search_contract.'">'; print '</td>'; print '<td class="liste_titre">'; - print '<input type="text" class="flat" size="18" name="search_service" value="'.stripslashes($search_service).'">'; + print '<input type="text" class="flat" size="18" name="search_service" value="'.$search_service.'">'; print '</td>'; print '<td class="liste_titre">'; - print '<input type="text" class="flat" size="24" name="search_nom" value="'.stripslashes($search_nom).'">'; + print '<input type="text" class="flat" size="24" name="search_nom" value="'.$search_nom.'">'; print '</td>'; print '<td class="liste_titre" align="center">'; $arrayofoperators=array('<'=>'<','>'=>'>'); @@ -178,6 +180,9 @@ if ($resql) print "</tr>\n"; print '</form>'; + $contractstatic=new Contrat($db); + $productstatic=new Product($db); + $var=True; while ($i < min($num,$limit)) { @@ -185,7 +190,6 @@ if ($resql) $var=!$var; print "<tr $bc[$var]>"; print '<td>'; - $contractstatic=new Contrat($db); $contractstatic->id=$obj->cid; $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; print $contractstatic->getNomUrl(1,16); @@ -193,14 +197,10 @@ if ($resql) // Service print '<td>'; - if ($obj->pid) - { - print '<a href="../product/fiche.php?id='.$obj->pid.'">'.img_object($langs->trans("ShowService"),"service").' '.dol_trunc($obj->label,20).'</a>'; - } - else - { - print dol_trunc($obj->description,20); - } + $productstatic->id=$obj->pid; + $productstatic->type=$obj->ptype; + $productstatic->ref=$obj->label?$obj->label:$obj->pid; + print $productstatic->getNomUrl(1,20); print '</td>'; // Third party diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 4729c4897dd7b1263abbc4dfc4649c5e0918701d..34ebab31aceaf83c3ad465255757646bdb9b25d7 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -2050,7 +2050,7 @@ class Product extends CommonObject } /** - * \brief Renvoie nom clicable (avec eventuellement le picto) + * \brief Return clicable link of object (with eventually picto) * \param withpicto Inclut le picto dans le lien * \param option Sur quoi pointe le lien * \param maxlength Maxlength of ref @@ -2084,9 +2084,9 @@ class Product extends CommonObject } /** - * \brief Retourne le libell� du statut d'une facture (brouillon, valid�e, abandonn�e, pay�e) - * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Picto - * \return string Libelle + * \brief Return label of status of object + * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * \return string Label of status */ function getLibStatut($mode=0) { @@ -2094,10 +2094,10 @@ class Product extends CommonObject } /** - * \brief Renvoi le libell� d'un statut donne + * \brief Return label of a given status * \param status Statut - * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Picto - * \return string Libell� du statut + * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * \return string Label of status */ function LibStatut($status,$mode=0) { diff --git a/htdocs/service.class.php b/htdocs/service.class.php index 5d5fbbaec218f62286e248b86a7490e8e89bb8ca..b8430312cdee67a177a9f9ae75c843322e7e8b5f 100644 --- a/htdocs/service.class.php +++ b/htdocs/service.class.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> - * + * * 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 @@ -31,204 +31,67 @@ */ class Service { - var $db; - - var $id; - var $libelle; - var $price; - var $tms; - var $debut; - var $fin; - - var $debut_epoch; - var $fin_epoch; - - - function Service($DB, $id=0) { - $this->db = $DB; - $this->id = $id; - - return 1; - } - - /* - * - * - * - */ - - function create($user) { - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."service (datec, fk_user_author) VALUES (".$this->db->idate(mktime()).", ".$user->id.")"; - - if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."service"); - - if ( $this->update($id, $user) ) { - return $id; - } - } else { - print $this->db->error() . ' in ' . $sql; - return -1; - } - } - - /* - * - * - * - */ - - function update($id, $user) { - - $sql = "UPDATE ".MAIN_DB_PREFIX."service "; - $sql .= " SET label = '" . trim($this->libelle) ."'"; - $sql .= ",ref = '" . trim($this->ref) ."'"; - $sql .= ",price = " . $this->price ; - $sql .= ",description = '" . trim($this->description) ."'"; - $sql .= ",fk_user_modif = " . $user->id ; - - $sql .= " WHERE rowid = " . $id; - - if ( $this->db->query($sql) ) { - return 1; - } else { - print $this->db->error() . ' in ' . $sql; - } - } - - /* - * - * - * - */ - - function start_comm($id, $user, $datedeb=0) { - - $sql = "UPDATE ".MAIN_DB_PREFIX."service "; - if ($datedeb) { - $sql .= " SET debut_comm = '$datedeb'"; - } else { - $sql .= " SET debut_comm = ".$this->db->idate(mktime()); - } - $sql .= ",fk_user_modif = " . $user->id ; - - $sql .= " WHERE rowid = " . $id; - - if ( $this->db->query($sql) ) { - return 1; - } else { - print $this->db->error() . ' in ' . $sql; - } - } - - /* - * - * - * - */ - - function stop_comm($id, $user, $datefin=0) { - - $sql = "UPDATE ".MAIN_DB_PREFIX."service "; - if ($datefin) { - $sql .= " SET fin_comm = '$datefin'"; - } else { - $sql .= " SET fin_comm = ".$this->db->idate(mktime()); - } - $sql .= ",fk_user_modif = " . $user->id ; - - $sql .= " WHERE rowid = " . $id; - - if ( $this->db->query($sql) ) { - return 1; - } else { - print $this->db->error() . ' in ' . $sql; - } - } - - /* - * - * - * - */ - - function fetch($id) { - - $sql = "SELECT s.ref,s.label,s.price,s.tms,s.debut_comm,s.fin_comm,s.description,"; - $sql .= $this->db->pdate("s.debut_comm") . ' as debut_epoch,'; - $sql .= $this->db->pdate("s.fin_comm") . ' as fin_epoch'; - $sql .= " FROM ".MAIN_DB_PREFIX."service as s"; - $sql .= " WHERE s.rowid = $id"; - - $result = $this->db->query($sql); - - if ($result) { - if ($this->db->num_rows()) { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->libelle = $obj->label; - $this->price = $obj->price; - $this->description = $obj->description; - - $this->tms = $obj->tms; - - $this->debut = $obj->debut_comm; - $this->fin = $obj->fin_comm; - - $this->debut_epoch = $obj->debut_epoch; - $this->fin_epoch = $obj->fin_epoch; - - } - $this->db->free(); - - } else { - print $this->db->error(); - } - } - - /** - * \brief Charge indicateurs this->nb de tableau de bord - * \return int <0 si ko, >0 si ok - */ - function load_state_board() - { - global $conf, $user; - - $this->nb=array(); - - $sql = "SELECT count(p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - if ($conf->categorie->enabled && !$user->rights->categorie->voir) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; - } - $sql.= " WHERE p.fk_product_type = 1"; - $sql.= " AND p.entity = ".$conf->entity; - if ($conf->categorie->enabled && !$user->rights->categorie->voir) - { - $sql.= " AND IFNULL(c.visible,1)=1"; - } - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { - $this->nb["services"]=$obj->nb; - } - return 1; - } - else - { - dol_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } + var $db; + + var $id; + var $libelle; + var $price; + var $tms; + var $debut; + var $fin; + + var $debut_epoch; + var $fin_epoch; + + + function Service($DB, $id=0) { + $this->db = $DB; + $this->id = $id; + + return 1; + } + + + /** + * \brief Charge indicateurs this->nb de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf, $user; + + $this->nb=array(); + + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + if ($conf->categorie->enabled && !$user->rights->categorie->voir) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; + } + $sql.= " WHERE p.fk_product_type = 1"; + $sql.= " AND p.entity = ".$conf->entity; + if ($conf->categorie->enabled && !$user->rights->categorie->voir) + { + $sql.= " AND IFNULL(c.visible,1)=1"; + } + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["services"]=$obj->nb; + } + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + + } - } - } ?>