diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 2508e9ad50e..112ffc8d5b7 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * 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 @@ -31,6 +31,10 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/project.class.php"); +if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php")) +{ + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php"); +} // Sécurité accés client if ($user->societe_id > 0) @@ -42,21 +46,8 @@ if ($user->societe_id > 0) if ($_GET["socidp"]) { - $sql = "SELECT s.nom, s.idp, s.prefix_comm FROM ".MAIN_DB_PREFIX."societe as s WHERE s.idp = ".$_GET["socidp"]; - - $result = $db->query($sql); - if ($result) - { - if ( $db->num_rows($result) ) - { - $objsoc = $db->fetch_object($result); - } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } + $objsoc=new Societe($db); + $objsoc->fetch($_GET["socidp"]); } @@ -126,9 +117,11 @@ if ($_GET["action"] == 'create') { print_titre($langs->trans("AddIntervention")); - $numpr = "FI-"."-" . strftime("%y%m%d", time()); + // \todo Utiliser un module de numérotation + $numpr = "FI".strftime("%y%m%d", time()); - $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'"; + $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " WHERE ref like '".$numpr."%'"; $resql=$db->query($sql); if ($resql) @@ -142,7 +135,14 @@ if ($_GET["action"] == 'create') } $fix = new Fichinter($db); - $numpr = $fix->get_new_num($objsoc->prefix_comm); + + $obj = $conf->global->FICHEINTER_ADDON; + +// \todo Quand module numerotation fiche inter sera dispo +// $modFicheinter = new $obj; +// $numpr = $modFicheinter->getNextValue($soc); + + $numpr = $fix->get_new_num($objsoc); print "
"; @@ -151,7 +151,7 @@ if ($_GET["action"] == 'create') print ''; print ''; - print ""; + print ""; print "
".$langs->trans("Company")."".$objsoc->nom."
".$langs->trans("Company")."".img_object($langs->trans("ShowCompany"),'company').' '.$objsoc->nom_url."
".$langs->trans("Date").""; $sel->select_date(time(),"p",'','','','fichinter'); diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index fd445e945b6..a7148aeb200 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -137,20 +137,23 @@ class Fichinter } /* - * + * \todo A virer quand module de numerotation dispo sur les fiches interventions * */ - function get_new_num($prefix_comm) + function get_new_num($societe) { - $sql = "SELECT max(ref) FROM ".MAIN_DB_PREFIX."fichinter WHERE ref like 'FI-".$prefix_comm."-%'"; + $sql = "SELECT max(ref) FROM ".MAIN_DB_PREFIX."fichinter"; + $sql.= " WHERE ref like 'FI".$societe->prefix_comm."%'"; - if ($this->db->query($sql) ) + $result=$this->db->query($sql); + if ($result) { - if ($this->db->num_rows()) + if ($this->db->num_rows($result)) { $row = $this->db->fetch_row(0); $num = $row[0]; + /* *$num = substr($num, strlen($num) - 4, 4); *$num = $num + 1; @@ -163,7 +166,7 @@ class Fichinter $num = $num + 1; //$num = '0000' . $num; //$num = 'FI-' . $prefix_comm . '-' . substr($num, strlen($num) - 4, 4); - $num = 'FI-' . $prefix_comm . '-' . $num; + $num = 'FI-' . $societe->prefix_comm . '-' . $num; return $num; } }