Fix: uniform code

This commit is contained in:
Regis Houssin 2011-10-27 15:33:18 +02:00
parent b861f3596b
commit 892de8a3d2

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* 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
@ -43,43 +43,25 @@ if (! empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."
$langs->load("companies"); $langs->load("companies");
$langs->load("interventions"); $langs->load("interventions");
$id=GETPOST('id'); $id = GETPOST('id');
$action=GETPOST("action"); $ref = GETPOST('ref');
$mesg=GETPOST("msg"); $socid = GETPOST('socid');
$action = GETPOST("action");
// Load object if defined $confirm = GETPOST("confirm");
$fichinterid=0; $mesg = GETPOST("msg");
$object = new Fichinter($db);
if ($id > 0 || ! empty($_GET["ref"]))
{
$result=$object->fetch($id,$_GET["ref"]);
if (! $result > 0)
{
dol_print_error($db);
exit;
}
$fichinterid=$object->id;
}
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
/* /*
* Actions * Actions
*/ */
if ($action != 'create' && $action != 'add' && $action != 'classifybilled' && ! ($_REQUEST["id"] > 0) && empty($_REQUEST["ref"])) if ($action == 'confirm_validate' && $confirm == 'yes')
{ {
Header("Location: ".DOL_URL_ROOT.'/fichinter/list.php');
exit;
}
if ($action == 'confirm_validate' && $_REQUEST['confirm'] == 'yes')
{
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -106,9 +88,8 @@ if ($action == 'confirm_validate' && $_REQUEST['confirm'] == 'yes')
} }
} }
if ($action == 'confirm_modify' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_modify' && $confirm == 'yes')
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -135,17 +116,17 @@ if ($action == 'confirm_modify' && $_REQUEST['confirm'] == 'yes')
} }
} }
if ($_POST["action"] == 'add') if ($action == 'add')
{ {
$object = new Fichinter($db); $object = new Fichinter($db);
$object->socid = $_POST["socid"]; $object->socid = $socid;
$object->duree = $_POST["duree"]; $object->duree = $_POST["duree"];
$object->fk_project = $_POST["projectid"]; $object->fk_project = $_POST["projectid"];
$object->author = $user->id; $object->author = $user->id;
$object->description = $_POST["description"]; $object->description = $_POST["description"];
$object->ref = $_POST["ref"]; $object->ref = $ref;
$object->modelpdf = $_POST["model"]; $object->modelpdf = $_POST["model"];
if ($object->socid > 0) if ($object->socid > 0)
{ {
@ -153,14 +134,12 @@ if ($_POST["action"] == 'add')
if ($result > 0) if ($result > 0)
{ {
$id=$result; // Force raffraichissement sur fiche venant d'etre cree $id=$result; // Force raffraichissement sur fiche venant d'etre cree
$fichinterid=$result;
} }
else else
{ {
$langs->load("errors"); $langs->load("errors");
$mesg='<div class="error">'.$langs->trans($object->error).'</div>'; $mesg='<div class="error">'.$langs->trans($object->error).'</div>';
$action = 'create'; $action = 'create';
$_GET["socid"] = $_POST["socid"];
} }
} }
else else
@ -170,16 +149,15 @@ if ($_POST["action"] == 'add')
} }
} }
if ($_POST["action"] == 'update') if ($action == 'update')
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->socid = $_POST["socid"]; $object->socid = $socid;
$object->fk_project = $_POST["projectid"]; $object->fk_project = $_POST["projectid"];
$object->author = $user->id; $object->author = $user->id;
$object->description = $_POST["description"]; $object->description = $_POST["description"];
$object->ref = $_POST["ref"]; $object->ref = $ref;
$object->update($user); $object->update($user);
} }
@ -189,7 +167,6 @@ if ($_POST["action"] == 'update')
*/ */
if ($action == 'builddoc') // En get ou en post if ($action == 'builddoc') // En get ou en post
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->fetch_lines(); $object->fetch_lines();
@ -220,17 +197,15 @@ if ($action == 'builddoc') // En get ou en post
// Set into a project // Set into a project
if ($action == 'classin') if ($action == 'classin')
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$result=$object->setProject($_POST['projectid']); $result=$object->setProject($_POST['projectid']);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_delete' && $confirm == 'yes')
{ {
if ($user->rights->ficheinter->supprimer) if ($user->rights->ficheinter->supprimer)
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->delete($user); $object->delete($user);
} }
@ -240,7 +215,6 @@ if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
if ($action == 'setdescription') if ($action == 'setdescription')
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$result=$object->set_description($user,$_POST['description']); $result=$object->set_description($user,$_POST['description']);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
@ -263,8 +237,7 @@ if ($action == "addline" && $user->rights->ficheinter->creer)
{ {
$db->begin(); $db->begin();
$object = new Fichinter($db); $ret=$object->fetch($id);
$ret=$object->fetch($_POST['fichinterid']);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$desc=$_POST['np_desc']; $desc=$_POST['np_desc'];
@ -272,7 +245,7 @@ if ($action == "addline" && $user->rights->ficheinter->creer)
$duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']); $duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']);
$result=$object->addline( $result=$object->addline(
$_POST['fichinterid'], $id,
$desc, $desc,
$date_intervention, $date_intervention,
$duration $duration
@ -294,7 +267,7 @@ if ($action == "addline" && $user->rights->ficheinter->creer)
$db->commit(); $db->commit();
fichinter_create($db, $object, $object->modelpdf, $outputlangs); fichinter_create($db, $object, $object->modelpdf, $outputlangs);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_POST['fichinterid']); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
else else
@ -308,12 +281,11 @@ if ($action == "addline" && $user->rights->ficheinter->creer)
// Classify Billed // Classify Billed
if ($action == 'classifybilled') if ($action == 'classifybilled')
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$result=$object->setBilled(); $result=$object->setBilled();
if ($result > 0) if ($result > 0)
{ {
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_POST['fichinterid']); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
else else
@ -325,31 +297,30 @@ if ($action == 'classifybilled')
/* /*
* Mise a jour d'une ligne d'intervention * Mise a jour d'une ligne d'intervention
*/ */
if ($action == 'updateligne' && $user->rights->ficheinter->creer && $_POST["save"] == $langs->trans("Save")) if ($action == 'updateline' && $user->rights->ficheinter->creer && $_POST["save"] == $langs->trans("Save"))
{ {
$fichinterline = new FichinterLigne($db); $objectline = new FichinterLigne($db);
if ($fichinterline->fetch($_POST['ligne']) <= 0) if ($objectline->fetch($_POST['line_id']) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$object = new Fichinter($db); if ($object->fetch($objectline->fk_fichinter) <= 0)
if ($object->fetch($fichinterline->fk_fichinter) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$desc=$_POST['np_desc']; $desc = $_POST['np_desc'];
$date_intervention = dol_mktime($_POST["dihour"], $_POST["dimin"], 0, $_POST["dimonth"], $_POST["diday"], $_POST["diyear"]); $date_inter = dol_mktime($_POST["dihour"], $_POST["dimin"], 0, $_POST["dimonth"], $_POST["diday"], $_POST["diyear"]);
$duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']); $duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']);
$fichinterline->datei=$date_intervention; $objectline->datei = $date_inter;
$fichinterline->desc=$desc; $objectline->desc = $desc;
$fichinterline->duration=$duration; $objectline->duration = $duration;
$result = $fichinterline->update(); $result = $objectline->update();
if ($result < 0) if ($result < 0)
{ {
dol_print_error($db); dol_print_error($db);
@ -368,34 +339,26 @@ if ($action == 'updateligne' && $user->rights->ficheinter->creer && $_POST["save
} }
fichinter_create($db, $object, $object->modelpdf, $outputlangs); fichinter_create($db, $object, $object->modelpdf, $outputlangs);
unset($_POST['dihour']); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
unset($_POST['dimin']);
unset($_POST['dimonth']);
$dateintervention='';
unset($_POST['np_desc']);
unset($_POST['durationhour']);
unset($_POST['durationmin']);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_POST['fichinterid']);
exit; exit;
} }
/* /*
* Supprime une ligne d'intervention AVEC confirmation * Supprime une ligne d'intervention AVEC confirmation
*/ */
if ($action == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_deleteline' && $confirm == 'yes')
{ {
if ($user->rights->ficheinter->creer) if ($user->rights->ficheinter->creer)
{ {
$fichinterline = new FichinterLigne($db); $objectline = new FichinterLigne($db);
if ($fichinterline->fetch($_GET['ligne']) <= 0) if ($objectline->fetch($_GET['line_id']) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$result=$fichinterline->deleteline(); $result=$objectline->deleteline();
$object = new Fichinter($db);
if ($object->fetch($fichinterline->fk_fichinter) <= 0) if ($object->fetch($objectline->fk_fichinter) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
@ -413,7 +376,7 @@ if ($action == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes')
} }
fichinter_create($db, $object, $object->modelpdf, $outputlangs); fichinter_create($db, $object, $object->modelpdf, $outputlangs);
} }
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
@ -423,10 +386,9 @@ if ($action == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes')
if ($action == 'up' && $user->rights->ficheinter->creer) if ($action == 'up' && $user->rights->ficheinter->creer)
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->line_up($_GET['rowid']); $object->line_up($_GET['line_id']);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
@ -439,16 +401,15 @@ if ($action == 'up' && $user->rights->ficheinter->creer)
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
fichinter_create($db, $object, $object->modelpdf, $outputlangs); fichinter_create($db, $object, $object->modelpdf, $outputlangs);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$_GET['line_id']);
exit; exit;
} }
if ($action == 'down' && $user->rights->ficheinter->creer) if ($action == 'down' && $user->rights->ficheinter->creer)
{ {
$object = new Fichinter($db);
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->line_down($_GET['rowid']); $object->line_down($_GET['line_id']);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
@ -461,7 +422,7 @@ if ($action == 'down' && $user->rights->ficheinter->creer)
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
fichinter_create($db, $object, $object->modelpdf, $outputlangs); fichinter_create($db, $object, $object->modelpdf, $outputlangs);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$_GET['line_id']);
exit; exit;
} }
@ -505,11 +466,10 @@ if ($action == 'send' && ! $_POST['cancel'] && (empty($conf->global->MAIN_USE_AD
{ {
$langs->load('mails'); $langs->load('mails');
$object = new Fichinter($db); if ($object->fetch($id) > 0)
if ( $object->fetch($_POST['fichinter_id']) )
{ {
$ficheinterref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$file = $conf->ficheinter->dir_output . '/' . $ficheinterref . '/' . $ficheinterref . '.pdf'; $file = $conf->ficheinter->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
if (is_readable($file)) if (is_readable($file))
{ {
@ -540,11 +500,11 @@ if ($action == 'send' && ! $_POST['cancel'] && (empty($conf->global->MAIN_USE_AD
{ {
$langs->load("commercial"); $langs->load("commercial");
$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message']; $message = $_POST['message'];
$sendtocc = $_POST['sendtocc']; $sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt']; $deliveryreceipt = $_POST['deliveryreceipt'];
if ($action == 'send') if ($action == 'send')
{ {
@ -592,7 +552,7 @@ if ($action == 'send' && ! $_POST['cancel'] && (empty($conf->global->MAIN_USE_AD
$object->actionmsg = $actionmsg; $object->actionmsg = $actionmsg;
$object->actionmsg2 = $actionmsg2; $object->actionmsg2 = $actionmsg2;
$object->fk_element = $object->id; $object->fk_element = $object->id;
$object->elementtype = $object->element; $object->elementtype = $object->element;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@ -671,11 +631,7 @@ if ($action == 'create')
* Creation d'une nouvelle fiche d'intervention * Creation d'une nouvelle fiche d'intervention
*/ */
$societe=new Societe($db); $soc=new Societe($db);
if ($_GET["socid"] > 0)
{
$societe->fetch($_GET["socid"]);
}
print_fiche_titre($langs->trans("AddIntervention")); print_fiche_titre($langs->trans("AddIntervention"));
@ -687,25 +643,25 @@ if ($action == 'create')
exit; exit;
} }
$ficheinter = new Fichinter($db); $object->date = dol_now();
$ficheinter->date = time();
if ($fichinterid) $result=$ficheinter->fetch($fichinterid);
$obj = $conf->global->FICHEINTER_ADDON; $obj = $conf->global->FICHEINTER_ADDON;
$obj = "mod_".$obj; $obj = "mod_".$obj;
$modFicheinter = new $obj; $modFicheinter = new $obj;
$numpr = $modFicheinter->getNextValue($societe,$ficheinter); $numpr = $modFicheinter->getNextValue($soc, $object);
if ($_GET["socid"] > 0) if ($socid > 0)
{ {
$soc->fetch($socid);
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<input type="hidden" name="socid" value='.$_GET["socid"].'>'; print '<input type="hidden" name="socid" value='.$soc->id.'>';
print '<tr><td class="fieldrequired">'.$langs->trans("Thirdparty").'</td><td>'.$societe->getNomUrl(1).'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -719,10 +675,10 @@ if ($action == 'create')
$langs->load("project"); $langs->load("project");
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
$numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); $numprojet=select_projects($soc->id,$_POST["projectid"],'projectid');
if ($numprojet==0) if ($numprojet==0)
{ {
print ' &nbsp; <a href="../projet/fiche.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>'; print ' &nbsp; <a href="'.DOL_DOCUMENT_ROOT.'/projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
} }
print '</td></tr>'; print '</td></tr>';
} }
@ -751,9 +707,9 @@ if ($action == 'create')
} }
else else
{ {
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="GET">'; print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="fieldrequired">'.$langs->trans("Thirdparty").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>';
$html->select_societes('','socid','',1,1); $html->select_societes('','socid','',1,1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -767,20 +723,20 @@ if ($action == 'create')
} }
} }
elseif ($fichinterid) else if ($id > 0 || ! empty($ref))
{ {
/* /*
* Affichage en mode visu * Affichage en mode visu
*/ */
$object->fetch($id, $ref);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$societe=new Societe($db); $soc=new Societe($db);
$societe->fetch($object->socid); $soc->fetch($object->socid);
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
$head = fichinter_prepare_head($object); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), 0, 'intervention'); dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), 0, 'intervention');
@ -809,7 +765,7 @@ elseif ($fichinterid)
// Confirmation de la suppression d'une ligne d'intervention // Confirmation de la suppression d'une ligne d'intervention
if ($action == 'ask_deleteline') if ($action == 'ask_deleteline')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&ligne='.$_GET["ligne"], $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$_GET["line_id"], $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -825,9 +781,7 @@ elseif ($fichinterid)
// Duration // Duration
print '<tr><td>'.$langs->trans("TotalDuration").'</td>'; print '<tr><td>'.$langs->trans("TotalDuration").'</td>';
//print $object->duree.'-'.$conf->global->MAIN_DURATION_OF_WORKDAY;
print '<td>'.ConvertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; print '<td>'.ConvertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
//print '<td>'.ConvertSecondToTime(90000,'all',$conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
print '</tr>'; print '</tr>';
// Description (must be a textarea and not html must be allowed (used in list view) // Description (must be a textarea and not html must be allowed (used in list view)
@ -895,7 +849,7 @@ elseif ($fichinterid)
$sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
$sql.= ' ft.date as date_intervention'; $sql.= ' ft.date as date_intervention';
$sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
$sql.= ' WHERE ft.fk_fichinter = '.$fichinterid; $sql.= ' WHERE ft.fk_fichinter = '.$object->id;
$sql.= ' ORDER BY ft.rang ASC, ft.rowid'; $sql.= ' ORDER BY ft.rang ASC, ft.rowid';
$resql = $db->query($sql); $resql = $db->query($sql);
@ -922,7 +876,7 @@ elseif ($fichinterid)
$var=!$var; $var=!$var;
// Ligne en mode visu // Ligne en mode visu
if ($action != 'editline' || $_GET['ligne'] != $objp->rowid) if ($action != 'editline' || $_GET['line_id'] != $objp->rowid)
{ {
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'; print '<td>';
@ -942,12 +896,12 @@ elseif ($fichinterid)
if ($object->statut == 0 && $user->rights->ficheinter->creer) if ($object->statut == 0 && $user->rights->ficheinter->creer)
{ {
print '<td align="center">'; print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;ligne='.$objp->rowid.'#'.$objp->rowid.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;line_id='.$objp->rowid.'#'.$objp->rowid.'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=ask_deleteline&amp;ligne='.$objp->rowid.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=ask_deleteline&amp;line_id='.$objp->rowid.'">';
print img_delete(); print img_delete();
print '</a></td>'; print '</a></td>';
if ($num > 1) if ($num > 1)
@ -955,13 +909,13 @@ elseif ($fichinterid)
print '<td align="center">'; print '<td align="center">';
if ($i > 0) if ($i > 0)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=up&amp;rowid='.$objp->rowid.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=up&amp;line_id='.$objp->rowid.'">';
print img_up(); print img_up();
print '</a>'; print '</a>';
} }
if ($i < $num-1) if ($i < $num-1)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=down&amp;rowid='.$objp->rowid.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=down&amp;line_id='.$objp->rowid.'">';
print img_down(); print img_down();
print '</a>'; print '</a>';
} }
@ -977,13 +931,13 @@ elseif ($fichinterid)
} }
// Ligne en mode update // Ligne en mode update
if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && $_GET["ligne"] == $objp->rowid) if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && $_GET["line_id"] == $objp->rowid)
{ {
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$objp->rowid.'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$objp->rowid.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateligne">'; print '<input type="hidden" name="action" value="updateline">';
print '<input type="hidden" name="fichinterid" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="ligne" value="'.$_GET["ligne"].'">'; print '<input type="hidden" name="line_id" value="'.$_GET["line_id"].'">';
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'; print '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
@ -1036,7 +990,7 @@ elseif ($fichinterid)
// Ajout ligne d'intervention // Ajout ligne d'intervention
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#add" name="addinter" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#add" name="addinter" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="fichinterid" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="action" value="addline">'; print '<input type="hidden" name="action" value="addline">';
$var=false; $var=false;
@ -1107,8 +1061,8 @@ elseif ($fichinterid)
// Send // Send
if ($object->statut > 0) if ($object->statut > 0)
{ {
$ficheinterref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$file = $conf->ficheinter->dir_output . '/'.$ficheinterref.'/'.$ficheinterref.'.pdf'; $file = $conf->ficheinter->dir_output . '/'.$objectref.'/'.$objectref.'.pdf';
if (file_exists($file)) if (file_exists($file))
{ {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
@ -1168,7 +1122,7 @@ elseif ($fichinterid)
$var=true; $var=true;
//print "<br>\n"; //print "<br>\n";
$somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$societe->default_lang); $somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/* /*
* Linked object block * Linked object block
@ -1223,7 +1177,7 @@ elseif ($fichinterid)
$formmail->param['action']='send'; $formmail->param['action']='send';
$formmail->param['models']='fichinter_send'; $formmail->param['models']='fichinter_send';
$formmail->param['fichinter_id']=$object->id; $formmail->param['fichinter_id']=$object->id;
$formmail->param['returnurl']=DOL_URL_ROOT.'/fichinter/fiche.php?id='.$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
// Init list of files // Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')