From 65af06a068ba6ee71967af5487ef3b6aad1a17d6 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sat, 23 Dec 2006 14:43:52 +0000 Subject: [PATCH] Amelioration gestion des parametres de l'URL --- htdocs/fichinter/fiche.php | 301 +++++++++++++++++-------------------- 1 file changed, 141 insertions(+), 160 deletions(-) diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 144a261ac02..4a071ee5a99 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -21,10 +21,10 @@ */ /** - \file htdocs/fichinter/fiche.php - \brief Fichier fiche intervention - \ingroup ficheinter - \version $Revision$ + \file htdocs/fichinter/fiche.php + \brief Fichier fiche intervention + \ingroup ficheinter + \version $Revision$ */ require("./pre.inc.php"); @@ -33,7 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.ph require_once(DOL_DOCUMENT_ROOT."/project.class.php"); if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php")) { - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php"); + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php"); } $langs->load("companies"); @@ -45,15 +45,15 @@ if (!$user->rights->ficheinter->lire) accessforbidden(); if ($_GET["socid"]) { - $societe=new Societe($db); - $societe->fetch($_GET["socid"]); + $societe=new Societe($db); + $societe->fetch($_GET["socid"]); } // Sécurité accés client if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } @@ -63,42 +63,42 @@ if ($user->societe_id > 0) if ($_GET["action"] == 'valid') { - $fichinter = new Fichinter($db); - $fichinter->id = $_GET["id"]; - $result=$fichinter->valid($user, $conf->fichinter->outputdir); - if ($result < 0) $mesg='
'.$fichinter->error.'
'; + $fichinter = new Fichinter($db); + $fichinter->id = $_GET["id"]; + $result=$fichinter->valid($user, $conf->fichinter->outputdir); + if ($result < 0) $mesg='
'.$fichinter->error.'
'; } if ($_POST["action"] == 'add') { - $fichinter = new Fichinter($db); - - $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["pmonth"], $_POST["pday"], $_POST["pyear"])); - $fichinter->socid = $_POST["socid"]; - $fichinter->duree = $_POST["duree"]; - $fichinter->projet_id = $_POST["projetidp"]; - $fichinter->author = $user->id; - $fichinter->note = $_POST["note"]; - $fichinter->ref = $_POST["ref"]; - - $id = $fichinter->create(); - $_GET["id"]=$id; // Force raffraichissement sur fiche venant d'etre créée + $fichinter = new Fichinter($db); + + $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["pmonth"], $_POST["pday"], $_POST["pyear"])); + $fichinter->socid = $_POST["socid"]; + $fichinter->duree = $_POST["duree"]; + $fichinter->projet_id = $_POST["projetidp"]; + $fichinter->author = $user->id; + $fichinter->note = $_POST["note"]; + $fichinter->ref = $_POST["ref"]; + + $id = $fichinter->create(); + $_GET["id"]=$id; // Force raffraichissement sur fiche venant d'etre créée } if ($_POST["action"] == 'update') { - $fichinter = new Fichinter($db); - - $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); - $fichinter->socid = $_POST["socid"]; - $fichinter->duree = $_POST["duree"]; - $fichinter->projet_id = $_POST["projetidp"]; - $fichinter->author = $user->id; - $fichinter->note = $_POST["note"]; - $fichinter->ref = $_POST["ref"]; - - $fichinter->update($_POST["id"]); - $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre créée + $fichinter = new Fichinter($db); + + $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); + $fichinter->socid = $_POST["socid"]; + $fichinter->duree = $_POST["duree"]; + $fichinter->projet_id = $_POST["projetidp"]; + $fichinter->author = $user->id; + $fichinter->note = $_POST["note"]; + $fichinter->ref = $_POST["ref"]; + + $fichinter->update($_POST["id"]); + $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre créée } /* @@ -106,27 +106,22 @@ if ($_POST["action"] == 'update') */ if ($_REQUEST['action'] == 'builddoc') // En get ou en post { - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - $result=fichinter_pdf_create($db, $_REQUEST['id'], $_REQUEST['model'], $outputlangs); - if ($result <= 0) + if ($_REQUEST['lang_id']) { - dolibarr_print_error($db,$result); - exit; + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + $result=fichinter_pdf_create($db, $_REQUEST['id'], $_REQUEST['model'], $outputlangs); + if ($result <= 0) + { + dolibarr_print_error($db,$result); + exit; } } - - /* * Affichage page */ - -llxHeader(); - $html = new Form($db); /* @@ -137,27 +132,27 @@ $html = new Form($db); */ if ($_GET["action"] == 'create') { - print_titre($langs->trans("AddIntervention")); - - if (! $conf->global->FICHEINTER_ADDON) - { - dolibarr_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); - exit; - } - - $fix = new Fichinter($db); - - $file = "mod_".$conf->global->FICHEINTER_ADDON.".php"; - - $obj = "mod_".$conf->global->FICHEINTER_ADDON; - $modFicheinter = new $obj; - $numpr = $modFicheinter->getNextValue($societe); - - - print "
"; - - $smonth = 1; - $syear = date("Y", time()); + llxHeader(); + print_titre($langs->trans("AddIntervention")); + + if (! $conf->global->FICHEINTER_ADDON) + { + dolibarr_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); + exit; + } + + $fix = new Fichinter($db); + + $file = "mod_".$conf->global->FICHEINTER_ADDON.".php"; + + $obj = "mod_".$conf->global->FICHEINTER_ADDON; + $modFicheinter = new $obj; + $numpr = $modFicheinter->getNextValue($societe); + + print ""; + + $smonth = 1; + $syear = date("Y", time()); print ''; print ''; @@ -237,50 +232,49 @@ if ($_GET["action"] == 'create') print '
'; print '
'; } - - -/* -* -* Mode update -* Mise a jour de la fiche d'intervention -* -*/ -if ($_GET["action"] == 'edit') +elseif ($_GET["action"] == 'edit' && $_GET["id"] > 0) { - $fichinter = new Fichinter($db); - $fichinter->fetch($_GET["id"]); - $fichinter->fetch_client(); - - dolibarr_fiche_head($head, $a, $langs->trans("EditIntervention")); - - - print "
"; - - print ""; - print ""; - - print ''; - - // Ref - print ''; - - // Tiers - print ""; - - // Date - print ""; - - print ''; - - if ($conf->projet->enabled) - { - // Projet associé - print ''; - } + /* + * + * Mode update + * Mise a jour de la fiche d'intervention + * + */ + llxHeader(); + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET["id"]); + $fichinter->fetch_client(); + + dolibarr_fiche_head($head, $a, $langs->trans("EditIntervention")); + + + print ""; + + print ""; + print ""; + + print '
'.$langs->trans("Ref").''.$fichinter->ref.'
".$langs->trans("Company")."".$fichinter->client->getNomUrl(1)."
".$langs->trans("Date").""; - $html->select_date($fichinter->date,'','','','','update'); - print "
'.$langs->trans("Duration")." (".$langs->trans("days").')
'.$langs->trans("Project").''; - $html->select_projects($fichinter->societe_id,$fichinter->projet_id,"projetidp"); - print '
'; + + // Ref + print ''; + + // Tiers + print ""; + + // Date + print ""; + + print ''; + + if ($conf->projet->enabled) + { + // Projet associé + print ''; + } // Description print ''; @@ -303,42 +297,42 @@ if ($_GET["action"] == 'edit') print ''; - print '
'.$langs->trans("Ref").''.$fichinter->ref.'
".$langs->trans("Company")."".$fichinter->client->getNomUrl(1)."
".$langs->trans("Date").""; + $html->select_date($fichinter->date,'','','','','update'); + print "
'.$langs->trans("Duration")." (".$langs->trans("days").')
'.$langs->trans("Project").''; + $html->select_projects($fichinter->societe_id,$fichinter->projet_id,"projetidp"); + print '
'.$langs->trans("Description").'
'; print ''; print '
'; + print "\n"; print '
'; print ''; } - - -/* - * Affichage en mode visu - */ -if ($_GET["id"] && $_GET["action"] != 'edit') +elseif ($_GET["id"] > 0) { - if ($mesg) print $mesg."
"; + /* + * Affichage en mode visu + */ + llxHeader(); - dolibarr_fiche_head($head, $a, $langs->trans("InterventionCard")); - - $fichinter = new Fichinter($db); - $result=$fichinter->fetch($_GET["id"]); - if (! $result > 0) + if ($mesg) print $mesg."
"; + + dolibarr_fiche_head($head, $a, $langs->trans("InterventionCard")); + + $fichinter = new Fichinter($db); + $result=$fichinter->fetch($_GET["id"]); + if (! $result > 0) { - dolibarr_print_error($db); - exit; + dolibarr_print_error($db); + exit; } - $fichinter->fetch_client(); - - print ''; - - // Ref - print ''; - - // Societe - print ""; - - // Date - print ''; + $fichinter->fetch_client(); + + print '
'.$langs->trans("Ref").''.$fichinter->ref.'
".$langs->trans("Company")."".$fichinter->client->getNomUrl(1)."
'.$langs->trans("Date").''.dolibarr_print_date($fichinter->date,"%A %d %B %Y").'
'; + + // Ref + print ''; + + // Societe + print ""; + + // Date + print ''; // Durée print ''; @@ -380,24 +374,10 @@ if ($_GET["id"] && $_GET["action"] != 'edit') { print ''.$langs->trans("Valid").''; } - - if ($fichinter->statut == 0) - { - $langs->load("bills"); - print ''.$langs->trans("BuildPDF").''; - } - - if ($fichinter->statut > 0) - { - $langs->load("bills"); - print ''.$langs->trans("RebuildPDF").''; - } - } print ''; print '
'.$langs->trans("Ref").''.$fichinter->ref.'
".$langs->trans("Company")."".$fichinter->client->getNomUrl(1)."
'.$langs->trans("Date").''.dolibarr_print_date($fichinter->date,"%A %d %B %Y").'
'.$langs->trans("Duration").''.$fichinter->duree.'
"; print "
'; - /* * Documents générés */ @@ -414,14 +394,15 @@ if ($_GET["id"] && $_GET["action"] != 'edit') print "
\n"; $somethingshown=$html->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$ficheinter->modelpdf); - print "
"; - - print " "; - + print " 
\n"; } +else +{ + Header("Location: index.php"); +} $db->close();