Fix: Corrections problmes divers sur le module fiche interventions
This commit is contained in:
parent
02b9024a6f
commit
0c2bfc6f49
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,6 +20,12 @@
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/** \file htdocs/ficheinter.php
|
||||
\brief Fichier fiche intervention
|
||||
\ingroup ficheinter
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("./fichinter.class.php");
|
||||
require("../project.class.php");
|
||||
@ -160,9 +166,9 @@ if ($_GET["action"] == 'create')
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>';
|
||||
print "<tr><td>Société</td><td><b>".$objsoc->nom."</td></tr>";
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td><b>".$objsoc->nom."</td></tr>";
|
||||
|
||||
print "<tr><td>Date</td><td>";
|
||||
print "<tr><td>".$langs->trans("Date")."</td><td>";
|
||||
$cday = date("d", time());
|
||||
print "<select name=\"pday\">";
|
||||
for ($day = 1 ; $day < $sday + 32 ; $day++)
|
||||
@ -201,35 +207,36 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
||||
|
||||
print "<tr><td>Numéro</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
|
||||
print "<tr><td>Durée (en jours)</td><td><input name=\"duree\"></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";
|
||||
|
||||
/*
|
||||
* Projet associé
|
||||
*
|
||||
*/
|
||||
print '<tr><td valign="top">Projet</td><td><select name="projetidp">';
|
||||
print '<option value="0"></option>';
|
||||
if ($conf->projet->enabled) {
|
||||
// Projet associé
|
||||
$langs->load("project");
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
|
||||
print '<option value="0"></option>';
|
||||
|
||||
$sql = "SELECT p.rowid, p.title FROM ".MAIN_DB_PREFIX."projet as p WHERE p.fk_soc = $socidp";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$i = 0 ;
|
||||
$numprojet = $db->num_rows();
|
||||
while ($i < $numprojet)
|
||||
{
|
||||
$projet = $db->fetch_object();
|
||||
print "<option value=\"$projet->rowid\">$projet->title</option>";
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
print '</select>';
|
||||
|
||||
$sql = "SELECT p.rowid, p.title FROM ".MAIN_DB_PREFIX."projet as p WHERE p.fk_soc = $socidp";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$i = 0 ;
|
||||
$numprojet = $db->num_rows();
|
||||
while ($i < $numprojet)
|
||||
{
|
||||
$projet = $db->fetch_object();
|
||||
print "<option value=\"$projet->rowid\">$projet->title</option>";
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
print '</select>';
|
||||
if ($numprojet==0) {
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>'.$langs->trans("Add").'</a>';
|
||||
}
|
||||
|
||||
if ($numprojet==0) {
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -238,7 +245,7 @@ if ($_GET["action"] == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print "<input type=\"submit\" value=\"".$langs->trans("Save")."\">";
|
||||
print "<input type=\"submit\" value=\"".$langs->trans("Add")."\">";
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
@ -286,27 +293,23 @@ if ($_GET["action"] == 'edit')
|
||||
|
||||
print "</select></td></tr>";
|
||||
|
||||
print '<tr><td>Numéro</td><td>'.$fichinter->ref.'</td></tr>';
|
||||
print '<tr><td>Durée (en jours)</td><td><input name="duree" value="'.$fichinter->duree.'"></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>';
|
||||
|
||||
/*
|
||||
*
|
||||
* Projet associé
|
||||
*
|
||||
*/
|
||||
|
||||
print '<tr><td valign="top">Projet</td><td>';
|
||||
|
||||
$sel = new Form($db);
|
||||
$sel->select_array("projetidp",$listeprj,$fichinter->projet_id);
|
||||
|
||||
if (sizeof($listeprj) == 0)
|
||||
{
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if ($conf->projet->enabled) {
|
||||
// Projet associé
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$sel = new Form($db);
|
||||
$sel->select_array("projetidp",$listeprj,$fichinter->projet_id);
|
||||
|
||||
if (sizeof($listeprj) == 0)
|
||||
{
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
|
||||
print '<td><textarea name="note" wrap="soft" cols="60" rows="15">';
|
||||
@ -321,18 +324,14 @@ if ($_GET["action"] == 'edit')
|
||||
|
||||
print "</form>";
|
||||
|
||||
print "<hr noshade>";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Mode Fiche
|
||||
* Affichage de la fiche d'intervention
|
||||
*
|
||||
* Mode visu
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_GET["id"])
|
||||
if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
{
|
||||
print_fiche_titre("Fiche d'intervention",$mesg);
|
||||
|
||||
@ -341,12 +340,14 @@ if ($_GET["id"])
|
||||
{
|
||||
$fichinter->fetch_client();
|
||||
|
||||
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
|
||||
print '<tr><td>Société</td><td><a href="../comm/fiche.php?socid='.$fichinter->client->id.'">'.$fichinter->client->nom.'</a></td></tr>';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td><a href="../comm/fiche.php?socid='.$fichinter->client->id.'">'.$fichinter->client->nom.'</a></td></tr>';
|
||||
print '<tr><td width="20%">Date</td><td>'.strftime("%A %d %B %Y",$fichinter->date).'</td></tr>';
|
||||
print '<tr><td>Numéro</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 valign="top">Projet</td><td> </td></tr>';
|
||||
if ($conf->projet->enabled) {
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td> </td></tr>';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print nl2br($fichinter->note);
|
||||
@ -374,6 +375,7 @@ if ($_GET["id"])
|
||||
$file = $conf->ficheinter->dir_output . "/$fichinter->ref/$fichinter->ref.pdf";
|
||||
if ($fichinter->statut == 0 or !file_exists($file))
|
||||
{
|
||||
$langs->load("bills");
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=generate">'.$langs->trans("BuildPDF").'</a>';
|
||||
}
|
||||
|
||||
@ -399,7 +401,7 @@ if ($_GET["id"])
|
||||
if (file_exists($file))
|
||||
{
|
||||
print "<tr $bc[0]><td>Ficheinter PDF</a></td>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'.pdf">'.$fichinter->ref.'.pdf</a></td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'">'.$fichinter->ref.'.pdf</a></td>';
|
||||
print '<td align="right">'.filesize($file). ' bytes</td>';
|
||||
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td></tr>';
|
||||
}
|
||||
|
||||
@ -60,28 +60,40 @@ class Fichinter
|
||||
$this->products[$i] = $idproduct;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* \brief Crée une fiche intervention en base
|
||||
*
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
/*
|
||||
* Insertion dans la base
|
||||
*/
|
||||
if (!strlen($this->duree)) { $this->duree = 0; }
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."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, $this->projet_id)";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree";
|
||||
if ($this->projet_id) {
|
||||
$sql .= ",fk_projet";
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= " VALUES ($this->socidp, $this->date, now(), '$this->ref', $this->author, '$this->note', $this->duree";
|
||||
if ($this->projet_id) {
|
||||
$sql .= ", $this->projet_id";
|
||||
}
|
||||
$sql .= ")";
|
||||
$sqlok = 0;
|
||||
|
||||
if (! $this->db->query($sql) )
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
print $this->db->error() . '<b><br>'.$sql;
|
||||
return $this->db->last_insert_id();
|
||||
}
|
||||
return $this->db->last_insert_id();
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,6 +20,13 @@
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/ficheinter.php
|
||||
\brief Fichier fiche intervention
|
||||
\ingroup ficheinter
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("../contact.class.php");
|
||||
|
||||
@ -30,22 +37,12 @@ if ($user->societe_id > 0)
|
||||
|
||||
llxHeader();
|
||||
|
||||
/*
|
||||
* Liste
|
||||
*
|
||||
*/
|
||||
|
||||
$sortorder=$_GET["sortorder"]?$_GET["sortorder"]:$_POST["sortorder"];
|
||||
$sortfield=$_GET["sortfield"]?$_GET["sortfield"]:$_POST["sortfield"];
|
||||
|
||||
if ($sortorder == "")
|
||||
{
|
||||
$sortorder="DESC";
|
||||
}
|
||||
if ($sortfield == "")
|
||||
{
|
||||
$sortfield="f.datei";
|
||||
}
|
||||
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="f.datei";
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
|
||||
$limit = $conf->liste_limit;
|
||||
@ -77,7 +74,7 @@ if ( $db->query($sql) )
|
||||
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","&socid=$socid",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"index.php","f.datei","","&socid=$socid",'',$sortfield);
|
||||
print '<td align="center">'.$langs->trans("Duration").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td><td> </td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print "</tr>\n";
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
@ -85,35 +82,26 @@ if ( $db->query($sql) )
|
||||
$objp = $db->fetch_object();
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td><a href=\"fiche.php?id=$objp->fichid\">$objp->ref</a></td>\n";
|
||||
print "<td><a href=\"fiche.php?id=$objp->fichid\">".img_object($langs->trans("Show"),"task").' '.$objp->ref."</a></td>\n";
|
||||
|
||||
print '<td><a href="index.php?socid='.$objp->idp.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0"></a> ';
|
||||
print "<a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></td>\n";
|
||||
print '<td><a href="index.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom."</a></td>\n";
|
||||
print "<td>".strftime("%d %B %Y",$objp->dp)."</TD>\n";
|
||||
print '<td align="center">'.sprintf("%.1f",$objp->duree).'</td>';
|
||||
print '<Td align="center">'.$objp->fk_statut.'</td>';
|
||||
print '<td align="center">'.$objp->fk_statut.'</td>';
|
||||
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
print '<td align="center"><a href="fiche.php?socidp='.$objp->idp.'&action=create">[Fiche Inter]</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td> </td>";
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "</TABLE>";
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print $db->error();
|
||||
print "<p>$sql";
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user