Fix: Quelques correctifs sur gestion fiches interventions

This commit is contained in:
Laurent Destailleur 2006-04-29 00:59:41 +00:00
parent 676e13ee8a
commit 5141b2ed6b
2 changed files with 29 additions and 26 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -31,6 +31,10 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.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."/includes/modules/fichinter/modules_fichinter.php");
require_once(DOL_DOCUMENT_ROOT."/project.class.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 // Sécurité accés client
if ($user->societe_id > 0) if ($user->societe_id > 0)
@ -42,21 +46,8 @@ if ($user->societe_id > 0)
if ($_GET["socidp"]) if ($_GET["socidp"])
{ {
$sql = "SELECT s.nom, s.idp, s.prefix_comm FROM ".MAIN_DB_PREFIX."societe as s WHERE s.idp = ".$_GET["socidp"]; $objsoc=new Societe($db);
$objsoc->fetch($_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);
}
} }
@ -126,9 +117,11 @@ if ($_GET["action"] == 'create')
{ {
print_titre($langs->trans("AddIntervention")); 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); $resql=$db->query($sql);
if ($resql) if ($resql)
@ -142,7 +135,14 @@ if ($_GET["action"] == 'create')
} }
$fix = new Fichinter($db); $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 "<form name='fichinter' action=\"fiche.php\" method=\"post\">"; print "<form name='fichinter' action=\"fiche.php\" method=\"post\">";
@ -151,7 +151,7 @@ if ($_GET["action"] == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>'; print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>';
print "<tr><td>".$langs->trans("Company")."</td><td><b>".$objsoc->nom."</td></tr>"; print "<tr><td>".$langs->trans("Company")."</td><td>".img_object($langs->trans("ShowCompany"),'company').' '.$objsoc->nom_url."</td></tr>";
print "<tr><td>".$langs->trans("Date")."</td><td>"; print "<tr><td>".$langs->trans("Date")."</td><td>";
$sel->select_date(time(),"p",'','','','fichinter'); $sel->select_date(time(),"p",'','','','fichinter');

View File

@ -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); $row = $this->db->fetch_row(0);
$num = $row[0]; $num = $row[0];
/* /*
*$num = substr($num, strlen($num) - 4, 4); *$num = substr($num, strlen($num) - 4, 4);
*$num = $num + 1; *$num = $num + 1;
@ -163,7 +166,7 @@ class Fichinter
$num = $num + 1; $num = $num + 1;
//$num = '0000' . $num; //$num = '0000' . $num;
//$num = 'FI-' . $prefix_comm . '-' . substr($num, strlen($num) - 4, 4); //$num = 'FI-' . $prefix_comm . '-' . substr($num, strlen($num) - 4, 4);
$num = 'FI-' . $prefix_comm . '-' . $num; $num = 'FI-' . $societe->prefix_comm . '-' . $num;
return $num; return $num;
} }
} }