Nettoyage du code

This commit is contained in:
Rodolphe Quiedeville 2005-04-06 21:39:24 +00:00
parent 16c0de1577
commit 4cb25ed5eb

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2002-2004 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-2005 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
@ -20,7 +20,7 @@
* $Source$ * $Source$
*/ */
/** /*!
\file htdocs/fichinter/fiche.php \file htdocs/fichinter/fiche.php
\brief Fichier fiche intervention \brief Fichier fiche intervention
\ingroup ficheinter \ingroup ficheinter
@ -53,7 +53,8 @@ if ($_GET["socidp"])
} }
$db->free($result); $db->free($result);
} }
else { else
{
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
@ -68,7 +69,6 @@ if ($_GET["action"] == 'valid')
$fichinter = new Fichinter($db); $fichinter = new Fichinter($db);
$fichinter->id = $_GET["id"]; $fichinter->id = $_GET["id"];
$fichinter->valid($user->id, $conf->fichinter->outputdir); $fichinter->valid($user->id, $conf->fichinter->outputdir);
} }
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
@ -114,10 +114,8 @@ if ($_GET["action"] == 'generate' && $_GET["id"])
llxHeader(); llxHeader();
$sel = new Form($db); $sel = new Form($db);
/* /*
* *
* Mode creation * Mode creation
@ -128,17 +126,15 @@ if ($_GET["action"] == 'create')
{ {
print_titre($langs->trans("AddIntervention")); print_titre($langs->trans("AddIntervention"));
if ( $objsoc->prefix_comm ) $numpr = "FI-"."-" . strftime("%y%m%d", time());
{
$numpr = "FI-" . $objsoc->prefix_comm . "-" . 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 WHERE ref like '$numpr%'";
$result=$db->query($sql); $resql=$db->query($sql);
if ($result) if ($resql)
{ {
$num = $db->result(0, 0); $num = $db->result(0, 0);
$db->free($result); $db->free($resql);
if ($num > 0) if ($num > 0)
{ {
$numpr .= "." . ($num + 1); $numpr .= "." . ($num + 1);
@ -166,7 +162,8 @@ if ($_GET["action"] == 'create')
print "<tr><td>".$langs->trans("Ref")."</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n"; print "<tr><td>".$langs->trans("Ref")."</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
print "<tr><td>".$langs->trans("Duration")." (".$langs->trans("days").")</td><td><input name=\"duree\"></td></tr>\n"; print "<tr><td>".$langs->trans("Duration")." (".$langs->trans("days").")</td><td><input name=\"duree\"></td></tr>\n";
if ($conf->projet->enabled) { if ($conf->projet->enabled)
{
// Projet associ // Projet associ
$langs->load("project"); $langs->load("project");
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">'; print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
@ -188,10 +185,17 @@ if ($_GET["action"] == 'create')
} }
print '</select>'; print '</select>';
if ($numprojet==0) { if ($numprojet==0)
{
print 'Cette société n\'a pas de projet.&nbsp;'; print 'Cette société n\'a pas de projet.&nbsp;';
$user->getrights("projet");
if ($user->rights->projet->creer)
{
print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>'.$langs->trans("Add").'</a>'; print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>'.$langs->trans("Add").'</a>';
} }
}
} }
print '</td></tr>'; print '</td></tr>';
@ -206,15 +210,9 @@ if ($_GET["action"] == 'create')
print '</table>'; print '</table>';
print '</form>'; print '</form>';
}
else
{
print "Vous devez d'abord associer un prefixe commercial a cette societe" ;
}
} }
/* /*
* *
* Mode update * Mode update
@ -223,7 +221,6 @@ if ($_GET["action"] == 'create')
*/ */
if ($_GET["action"] == 'edit') if ($_GET["action"] == 'edit')
{ {
$fichinter = new Fichinter($db); $fichinter = new Fichinter($db);
$fichinter->fetch($_GET["id"]); $fichinter->fetch($_GET["id"]);
@ -233,7 +230,6 @@ if ($_GET["action"] == 'edit')
$prj = new Project($db); $prj = new Project($db);
$listeprj = $prj->liste_array($fichinter->societe_id); $listeprj = $prj->liste_array($fichinter->societe_id);
print_titre($langs->trans("EditIntervention")); print_titre($langs->trans("EditIntervention"));
print "<form action=\"fiche.php\" method=\"post\">"; print "<form action=\"fiche.php\" method=\"post\">";
@ -249,7 +245,8 @@ if ($_GET["action"] == 'edit')
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>'; print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Duration")." (".$langs->trans("days").')</td><td><input name="duree" value="'.$fichinter->duree.'"></td></tr>'; print '<tr><td>'.$langs->trans("Duration")." (".$langs->trans("days").')</td><td><input name="duree" value="'.$fichinter->duree.'"></td></tr>';
if ($conf->projet->enabled) { if ($conf->projet->enabled)
{
// Projet associ // Projet associ
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
@ -258,8 +255,14 @@ if ($_GET["action"] == 'edit')
if (sizeof($listeprj) == 0) if (sizeof($listeprj) == 0)
{ {
print 'Cette société n\'a pas de projet.&nbsp;'; print 'Cette société n\'a pas de projet.&nbsp;';
$user->getrights("projet");
if ($user->rights->projet->creer)
{
print '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php?socidp='.$socidp.'&action=create>Créer un projet</a>'; print '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php?socidp='.$socidp.'&action=create>Créer un projet</a>';
} }
}
print '</td></tr>'; print '</td></tr>';
} }
@ -297,7 +300,9 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
print '<tr><td width="20%">Date</td><td>'.strftime("%A %d %B %Y",$fichinter->date).'</td></tr>'; print '<tr><td width="20%">Date</td><td>'.strftime("%A %d %B %Y",$fichinter->date).'</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>'; print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>'; print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>';
if ($conf->projet->enabled) {
if ($conf->projet->enabled)
{
$fichinter->fetch_projet(); $fichinter->fetch_projet();
print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td>'.$fichinter->projet.'</td></tr>'; print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td>'.$fichinter->projet.'</td></tr>';
} }
@ -340,7 +345,6 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
} }
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print '<table width="50%" cellspacing="2"><tr><td width="50%" valign="top">'; print '<table width="50%" cellspacing="2"><tr><td width="50%" valign="top">';
@ -370,7 +374,6 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
} }
} }
$db->close(); $db->close();
llxFooter(); llxFooter();
?> ?>