diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 39d3df46583..c5fac1e4497 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -59,13 +59,13 @@ if ($_POST["action"] == 'add_action') if ($_POST["apmin"] == -1) $_POST["apmin"]='0'; if ($_POST["adhour"] == -1) $_POST["adhour"]='0'; if ($_POST["admin"] == -1) $_POST["admin"]='0'; - $datep=@mktime($_POST["aphour"], + $datep=dolibarr_mktime($_POST["aphour"], $_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $datea=@mktime($_POST["adhour"], + $datea=dolibarr_mktime($_POST["adhour"], $_POST["admin"], 0, $_POST["admonth"], @@ -240,13 +240,13 @@ if ($_POST["action"] == 'update') $action = new Actioncomm($db); $action->fetch($_POST["id"]); - $action->datep = @mktime($_POST["aphour"], + $action->datep = dolibarr_mktime($_POST["aphour"], $_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $action->date = @mktime($_POST["adhour"], + $action->date = dolibarr_mktime($_POST["adhour"], $_POST["admin"], 0, $_POST["admonth"], diff --git a/htdocs/fichinter/apercu.php b/htdocs/fichinter/apercu.php new file mode 100644 index 00000000000..7b362457125 --- /dev/null +++ b/htdocs/fichinter/apercu.php @@ -0,0 +1,258 @@ + + * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/fichinter/apercu.php + \ingroup fichinter + \brief Page de l'onglet aperçu d'une fiche d'intervention + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); + +$user->getrights('ficheinter'); + +if (!$user->rights->ficheinter->lire) + accessforbidden(); + +$langs->load('interventions'); + +require_once(DOL_DOCUMENT_ROOT.'/fichinter/fichinter.class.php'); + +if ($conf->projet->enabled) +{ + require_once(DOL_DOCUMENT_ROOT."/project.class.php"); +} + + +/* + * Sécurité accés client +*/ +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +llxHeader(); + +$html = new Form($db); + +/* *************************************************************************** */ +/* */ +/* Mode fiche */ +/* */ +/* *************************************************************************** */ + +if ($_GET["id"] > 0) { + $fichinter = new Fichinter($db); + + if ( $fichinter->fetch($_GET["id"], $user->societe_id) > 0) + { + $soc = new Societe($db, $fichinter->socid); + $soc->fetch($fichinter->socid); + + + $head = fichinter_prepare_head($fichinter); + dolibarr_fiche_head($head, 'preview', $langs->trans("InterventionCard")); + + + /* + * Fiche intervention + */ + $sql = 'SELECT s.nom, s.rowid, fi.fk_projet, fi.ref, fi.description, fi.fk_statut, '.$db->pdate('fi.datei').' as di,'; + $sql.= ' fi.fk_user_author, fi.fk_user_valid, fi.datec, fi.date_valid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'fichinter as fi'; + $sql.= ' WHERE fi.fk_soc = s.rowid'; + $sql.= ' AND fi.rowid = '.$fichinter->id; + if ($socid) $sql .= ' AND s.rowid = '.$socid; + + $result = $db->query($sql); + + if ($result) + { + if ($db->num_rows($result)) + { + $obj = $db->fetch_object($result); + + $societe = new Societe($db); + $societe->fetch($obj->rowid); + + print ''; + + // Ref + print '"; + print ''; + print ""; + + $nbrow=6; + print '"; + + + // Client + print ""; + print ''; + print ''; + + // Statut + print ''; + print "\n"; + print ''; + + // Date + print ''; + print "\n"; + print ''; + + // ligne 6 + // partie Gauche + print ''; + print ''; + print ''; + + // ligne 7 + // partie Gauche + print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref")."'.$fichinter->ref.'
'; + + /* + * Documents + */ + $fichinterref = sanitize_string($fichinter->ref); + $dir_output = $conf->fichinter->dir_output . "/"; + $filepath = $dir_output . $fichinterref . "/"; + $file = $filepath . $fichinterref . ".pdf"; + $filedetail = $filepath . $fichinterref . "-detail.pdf"; + $relativepath = "${fichinterref}/${fichinterref}.pdf"; + $relativepathdetail = "${fichinterref}/${fichinterref}-detail.pdf"; + + // Chemin vers png aperçus + $relativepathimage = "${fichinterref}/${fichinterref}.pdf.png"; + $fileimage = $file.".png"; // Si PDF d'1 page + $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page + + $var=true; + + // Si fichier PDF existe + if (file_exists($file)) + { + $encfile = urlencode($file); + print_titre($langs->trans("Documents")); + print ''; + + print ""; + + print ''; + print ''; + print ''; + print ''; + + // Si fichier detail PDF existe + if (file_exists($filedetail)) { // commande détaillée supplémentaire + print ""; + + print ''; + print ''; + print ''; + print ''; + } + print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.dolibarr_print_date(filemtime($file),'dayhour').'
Commande détaillée'.$commande->ref.'-detail.pdf'.filesize($filedetail). ' bytes'.dolibarr_print_date(filemtime($filedetail),'dayhour').'
\n"; + + // Conversion du PDF en image png si fichier png non existant + if (! file_exists($fileimage) && ! file_exists($fileimagebis)) + { + if (function_exists("imagick_readimage")) + { + $handle = imagick_readimage( $file ) ; + if ( imagick_iserror( $handle ) ) + { + $reason = imagick_failedreason( $handle ) ; + $description = imagick_faileddescription( $handle ) ; + + print "handle failed!
\nReason: $reason
\nDescription: $description
\n"; + } + imagick_convert( $handle, "PNG" ) ; + if ( imagick_iserror( $handle ) ) + { + $reason = imagick_failedreason( $handle ) ; + $description = imagick_faileddescription( $handle ) ; + print "handle failed!
\nReason: $reason
\nDescription: $description
\n"; + } + imagick_writeimages( $handle, $file .".png"); + } else { + $langs->load("other"); + print ''.$langs->trans("ErrorNoImagickReadimage").''; + } + } + } + + print "
".$langs->trans("Customer")."'; + print ''.$societe->nom.''; + print '
'.$langs->trans("Status").'".$commande->getLibStatut(4)."
'.$langs->trans("Date").'".dolibarr_print_date($commande->date,"daytext")."
'.$langs->trans('GlobalDiscount').''.$commande->remise_percent.'%
'.$langs->trans('AmountHT').''.price($commande->total_ht).''.$langs->trans("Currency".$conf->monnaie).'
'; + } + } else { + dolibarr_print_error($db); + } + } else { + // Commande non trouvée + print $langs->trans("ErrorPropalNotFound",$_GET["id"]); + } +} + +// Si fichier png PDF d'1 page trouvé +if (file_exists($fileimage)) + { + print ''; + } +// Si fichier png PDF de plus d'1 page trouvé +elseif (file_exists($fileimagebis)) + { + $multiple = $relativepathimage . "."; + + for ($i = 0; $i < 20; $i++) + { + $preview = $multiple.$i; + + if (file_exists($dir_output.$preview)) + { + print '

'; + } + } + } + + +print ''; + + +// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent +print '

'; +print '
'; + + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index acc13c386b7..8450e061109 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -62,7 +63,7 @@ if ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && ! $_REQUE return; } -if ($_GET["action"] == 'valid') +if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes') { $fichinter = new Fichinter($db); $fichinter->id = $_GET["id"]; @@ -73,7 +74,7 @@ if ($_GET["action"] == 'valid') if ($_POST["action"] == 'add') { $fichinter = new Fichinter($db); - + $fichinter->date = $db->idate(dolibarr_mktime(12, 1 , 1, $_POST["pmonth"], $_POST["pday"], $_POST["pyear"])); $fichinter->socid = $_POST["socid"]; $fichinter->duree = $_POST["duree"]; @@ -81,11 +82,14 @@ if ($_POST["action"] == 'add') $fichinter->author = $user->id; $fichinter->description = $_POST["description"]; $fichinter->ref = $_POST["ref"]; + $fichinter->modelpdf = $_POST["model"]; $result = $fichinter->create(); + if ($result > 0) { $_GET["id"]=$result; // Force raffraichissement sur fiche venant d'etre créée + $fichinterid=$result; } else { @@ -99,7 +103,6 @@ if ($_POST["action"] == 'update') $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->description = $_POST["description"]; @@ -127,6 +130,170 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post } } +/* + * Classer dans un projet + */ +if ($_POST['action'] == 'classin') +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->set_project($user, $_POST['projetidp']); +} + +if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') +{ + if ($user->rights->ficheinter->supprimer) + { + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->delete($user); + } + Header('Location: index.php?leftmenu=ficheinter'); + exit; +} + +if ($_POST['action'] == 'setdate_delivery') +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $result=$fichinter->set_date_delivery($user,dolibarr_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + if ($result < 0) dolibarr_print_error($db,$fichinter->error); +} + +if ($_POST['action'] == 'setdescription') +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $result=$fichinter->set_description($user,$_POST['description']); + if ($result < 0) dolibarr_print_error($db,$fichinter->error); +} + +/* + * Ajout d'une ligne d'intervention + */ +if ($_POST['action'] == "addligne" && $user->rights->ficheinter->creer) +{ + if ($_POST['np_desc'] && ($_POST['durationhour'] || $_POST['durationmin'])) + { + $fichinter = new Fichinter($db); + $ret=$fichinter->fetch($_POST['fichinterid']); + + $desc=$_POST['np_desc']; + $date_intervention = $db->idate(mktime(12, 1 , 1, $_POST["dimonth"], $_POST["diday"], $_POST["diyear"])); + $duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']); + + $fichinter->addline( + $_POST['fichinterid'], + $desc, + $date_intervention, + $duration + ); + + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_pdf_create($db, $fichinter->id, $fichinter->modelpdf, $outputlangs); + } +} + +/* + * Mise à jour d'une ligne d'intervention + */ +if ($_POST['action'] == 'updateligne' && $user->rights->ficheinter->creer && $_POST["save"] == $langs->trans("Save")) +{ + $fichinter = new Fichinter($db); + if (! $fichinter->fetch($_POST['fichinterid']) > 0) dolibarr_print_error($db); + + $desc=$_POST['desc']; + $date_intervention = $db->idate(mktime(12, 1 , 1, $_POST["dimonth"], $_POST["diday"], $_POST["diyear"])); + $duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']); + + $result = $fichinter->updateline($_POST['ligne'], + $desc, + $date_intervention, + $duration + ); + + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_pdf_create($db, $fichinter->id, $fichinter->modelpdf, $outputlangs); +} + + +/* + * Supprime une ligne d'intervention SANS confirmation + */ +if ($_GET['action'] == 'deleteline' && $user->rights->ficheinter->creer && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE) +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $result=$fichinter->delete_line($_GET['ligne']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_pdf_create($db, $fichinter->id, $fichinter->modelpdf, $outputlangs); +} + +/* + * Supprime une ligne d'intervention AVEC confirmation + */ +if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) +{ + if ($user->rights->ficheinter->creer) + { + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $result=$fichinter->delete_line($_GET['ligne']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_pdf_create($db, $fichinter->id, $fichinter->modelpdf, $outputlangs); + } + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']); + exit; +} + +/* + * Ordonnancement des lignes + */ + +if ($_GET['action'] == 'up' && $user->rights->ficheinter->creer) +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->line_up($_GET['rowid']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_pdf_create($db, $fichinter->id, $fichinter->modelpdf, $outputlangs); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); +} + +if ($_GET['action'] == 'down' && $user->rights->ficheinter->creer) +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->line_down($_GET['rowid']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_pdf_create($db, $fichinter->id, $fichinter->modelpdf, $outputlangs); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); + exit; +} /* @@ -158,7 +325,7 @@ if ($_GET["action"] == 'create') } $ficheinter = new Fichinter($db); - $result=$ficheinter->fetch($_GET["id"]); + $result=$ficheinter->fetch($fichinterid); $obj = $conf->global->FICHEINTER_ADDON; $file = $obj.".php"; @@ -180,7 +347,7 @@ if ($_GET["action"] == 'create') else { print "".$langs->trans("Company").""; - $html->select_societes('','socid',''); + $html->select_societes('','socid','',1); print ""; } @@ -193,9 +360,7 @@ if ($_GET["action"] == 'create') print "".$langs->trans("Ref").""; print "\n"; - print "".$langs->trans("Duration")." (".$langs->trans("days").")\n"; - - if ($conf->projet->enabled) + if ($conf->projet->enabled && $_GET["socid"]) { // Projet associe $langs->load("project"); @@ -223,6 +388,15 @@ if ($_GET["action"] == 'create') } print ''; } + + // Model + print ''; + print ''.$langs->trans("DefaultModel").''; + print ''; + $model=new ModelePDFFicheinter(); + $liste=$model->liste_modeles($db); + $html->select_array('model',$liste,$conf->global->FICHINTER_ADDON_PDF); + print ""; print ''.$langs->trans("Description").''; print ""; @@ -248,109 +422,20 @@ if ($_GET["action"] == 'create') print ''; print ''; } -elseif ($_GET["action"] == 'edit' && $_GET["id"] > 0) -{ - /* - * - * Mode update - * Mise a jour de la fiche d'intervention - * - */ - $fichinter = new Fichinter($db); - $fichinter->fetch($_GET["id"]); - $fichinter->fetch_client(); - - $head = fichinter_prepare_head($fichinter); - - dolibarr_fiche_head($head, 'card', $langs->trans("EditIntervention")); - - - print "
"; - - print ""; - print ""; - - print ''; - - // Ref - print ''; - - // Tiers - print ""; - - // Date - print ""; - - print ''; - - if ($conf->projet->enabled) - { - $societe=new Societe($db); - $societe->fetch($fichinter->societe_id); - $numprojet = $societe->has_projects(); - - // Projet associé - print ''; - } - - // Description - 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").''; - - if (!$numprojet) - { - print ''; - print ''; - - $user->getrights("projet"); - - if ($user->rights->projet->creer) - { - print ''; - } - print '
'.$langs->trans("NoProject").''.$langs->trans("Add").'
'; - } - else - { - $html->select_projects($fichinter->societe_id,$fichinter->projet_id,"projetidp"); - } - print '
'.$langs->trans("Description").''; - - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE) - { - // Editeur wysiwyg - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('description',$fichinter->description,280,'dolibarr_notes','In',true); - $doleditor->Create(); - } - else - { - print ''; - } - - print '
'; - print ''; - print '
\n"; - print '
'; - print ''; -} elseif ($_GET["id"] > 0) { /* * Affichage en mode visu */ + + $html = new Form($db); $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(); if ($mesg) print $mesg."
"; @@ -359,6 +444,32 @@ elseif ($_GET["id"] > 0) dolibarr_fiche_head($head, 'card', $langs->trans("InterventionCard")); + /* + * Confirmation de la suppression de la fiche d'intervention + */ + if ($_GET['action'] == 'delete') + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$fichinter->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete'); + print '
'; + } + + /* + * Confirmation de la validation de la fiche d'intervention + */ + if ($_GET['action'] == 'validate') + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$fichinter->id, $langs->trans('ValidateIntervention'), $langs->trans('ConfirmValidateIntervention'), 'confirm_validate'); + print '
'; + } + + /* + * Confirmation de la suppression d'une ligne d'intervention + */ + if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$fichinter->id.'&ligne='.$_GET["ligne"], $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline'); + print '
'; + } print ''; @@ -369,32 +480,334 @@ elseif ($_GET["id"] > 0) print ""; // Date - print ''; + print ''; + print ''; - // Durée - print ''; - - if ($conf->projet->enabled) - { - $fichinter->fetch_projet(); - print ''; + } + else + { + if ($fichinter->statut == 0 && $user->rights->ficheinter->creer) + { + if ($_GET['action'] != 'classer' && $fichinter->brouillon) print ''; + print '
".$langs->trans("Company")."".$fichinter->client->getNomUrl(1)."
'.$langs->trans("Date").''.dolibarr_print_date($fichinter->date,"daytext").'
'; + print ''; + if ($_GET['action'] != 'editdate_delivery' && $fichinter->brouillon) print ''; + print '
'; + print $langs->trans('Date'); + print 'id.'">'.img_edit($langs->trans('SetDateCreate'),1).'
'; + print '
'; + if ($_GET['action'] == 'editdate_delivery') + { + print '
'; + print ''; + $html->select_date($fichinter->date,'liv_','','','',"editdate_delivery"); + print ''; + print '
'; + } + else + { + print dolibarr_print_date($fichinter->date,'%a %d %B %Y'); + } + print '
'.$langs->trans("Duration").''.$fichinter->duree.'
'.$langs->trans("Project").''; - print ''; - print $fichinter->projet->title; - print ''; + // Projet + if ($conf->projet->enabled) + { + $langs->load("projects"); + print '
'; + print ''; + $societe=new Societe($db); + $societe->fetch($fichinter->socid); + $numprojet = $societe->has_projects(); + if (! $numprojet) + { + print '
'; + print $langs->trans('Project').'
'; + print '
'; + print $langs->trans("NoProject").'  '; + if ($fichinter->brouillon) print 'id.'&action=create>'.$langs->trans('AddProject').''; + print ''.img_edit($langs->trans('SetProject')).'
'; + print ''; + if ($_GET['action'] == 'classer') + { + $html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp, 'projetidp'); + } + else + { + $html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp, 'none'); + } print ''; + } + else + { + if (!empty($fichinter->projetidp)) + { + print ''; + print ''; + $proj = new Project($db); + $proj->fetch($fichinter->projetidp); + print ''; + print $proj->title; + print ''; + print ''; + } + else { + print ''; + print ' '; + } + } + } + print ''; + } + + // Durée + print ''.$langs->trans("TotalDuration").''.$fichinter->duree.''; + + // Description + print ''; + print ''; + if ($_GET['action'] != 'editdescription' && $fichinter->brouillon) print ''; + print '
'; + print $langs->trans('Description'); + print 'id.'">'.img_edit($langs->trans('SetDescription'),1).'
'; + print ''; + if ($_GET['action'] == 'editdescription') + { + print '
'; + print ''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE) + { + // Editeur wysiwyg + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('description',$fichinter->description,280,'dolibarr_notes','In',true); + $doleditor->Create(); + } + else + { + print ''; + } + print ''; + print '
'; } + else + { + print nl2br($fichinter->description); + } + print ''; + print ''; // Statut print ''.$langs->trans("Status").''.$fichinter->getLibStatut(4).''; - // Description - print ''.$langs->trans("Description").''; - print ''; - print nl2br($fichinter->description); - print ''; + print "
"; + + /* + * Lignes d'intervention + */ + print ''; - print "
"; - print ''; + $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang'; + $sql.= ', '.$db->pdate('ft.date').' as date_intervention'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; + $sql.= ' WHERE ft.fk_fichinter = '.$fichinterid; + $sql.= ' ORDER BY ft.rang ASC, ft.rowid'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + if ($num) + { + print ''; + print ''.$langs->trans('Description').''; + print ''.$langs->trans('Date').''; + print ''.$langs->trans('Duration').''; + print ' '; + print "\n"; + } + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + + // Ligne en mode visu + if ($_GET['action'] != 'editline' || $_GET['ligne'] != $objp->rowid) + { + print ''; + print ''; + print ''; // ancre pour retourner sur la ligne + print nl2br($objp->description); + + print ''.dolibarr_print_date($objp->date_intervention,'%a %d %B %Y').''; + print ''.ConvertSecondToTime($objp->duree).''; + + print "\n"; + + + // Icone d'edition et suppression + if ($fichinter->statut == 0 && $user->rights->ficheinter->creer) + { + print ''; + print 'rowid.'#'.$objp->rowid.'">'; + print img_edit(); + print ''; + print ''; + print ''; + if ($conf->global->PRODUIT_CONFIRM_DELETE_LINE) + { + if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?id='.$fichinter->id.'&ligne='.$objp->rowid.'&action=confirm_deleteline&confirm=yes'; + print 'trans("No").'\',\'deleteline'.$i.'\')">'; + print img_delete(); + } + else + { + print 'rowid.'">'; + print img_delete(); + } + } + else + { + print 'rowid.'">'; + print img_delete(); + } + print ''; + if ($num > 1) + { + print ''; + if ($i > 0) + { + print 'rowid.'">'; + print img_up(); + print ''; + } + if ($i < $num-1) + { + print 'rowid.'">'; + print img_down(); + print ''; + } + print ''; + } + } + else + { + print ' '; + } + + print ''; + } + + // Ligne en mode update + if ($fichinter->statut == 0 && $_GET["action"] == 'editline' && $user->rights->ficheinter->creer && $_GET["ligne"] == $objp->rowid) + { + print '
rowid.'" method="post">'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; // ancre pour retourner sur la ligne + + // éditeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$objp->description,164,'dolibarr_details'); + $doleditor->Create(); + } + else + { + print ''; + } + print ''; + + // Date d'intervention + print ''; + $html->select_date($objp->date_intervention,'di',0,0,0,"date_intervention"); + print ''; + + // Durée + print ''; + $html->select_duree('duration',$objp->duree); + print ''; + + print ''; + print '
'; + print '' . "\n"; + + print "
\n"; + } + + $i++; + } + + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + + /* + * Ajouter une ligne + */ + if ($fichinter->statut == 0 && $user->rights->ficheinter->creer && $_GET["action"] <> 'editline') + { + print ''; + print ''; + print ''; // ancre + print $langs->trans('Description').''; + print ''.$langs->trans('Date').''; + print ''.$langs->trans('Duration').''; + + print ' '; + print "\n"; + + // Ajout ligne d'intervention + print '
'; + print ''; + print ''; + + $var=true; + + print '\n"; + print ''; + // éditeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS_PERSO) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('np_desc','',100,'dolibarr_details'); + $doleditor->Create(); + } + else + { + print ''; + } + print ''; + + // Date d'intervention + print ''; + $html->select_date(time(),'di',0,0,0,"date_intervention"); + print ''; + + // Durée + print ''; + $html->select_duree('duration'); + print ''; + + print ''; + print ''; + + print '
'; + } + + print ''; + + print ''; + print "\n"; /** @@ -405,17 +818,39 @@ elseif ($_GET["id"] > 0) if ($user->societe_id == 0) { - - if ($fichinter->statut == 0) + // Validate + if ($fichinter->statut == 0 && $user->rights->ficheinter->creer) { - print ''.$langs->trans("Edit").''; + print 'use_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?id='.$fichinter->id.'&action=confirm_validate&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmValidateIntervention').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"'; + } + else + { + print 'href="fiche.php?id='.$_GET["id"].'&action=validate"'; + } + print '>'.$langs->trans("Valid").''; } - - if ($fichinter->statut == 0) + + // Delete + if ($fichinter->statut == 0 && $user->rights->ficheinter->supprimer) { - print ''.$langs->trans("Valid").''; + print 'use_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?id='.$fichinter->id.'&action=confirm_delete&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans("ConfirmDeleteIntervention").'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"'; + } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?id='.$fichinter->id.'&action=delete"'; + } + print '>'.$langs->trans('Delete').''; } - } + } + print ''; print ''; print '
'; @@ -425,8 +860,8 @@ elseif ($_GET["id"] > 0) $filename=sanitize_string($fichinter->ref); $filedir=$conf->fichinter->dir_output . "/".$fichinter->ref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id; - $genallowed=$user->rights->fichinter->creer; - $delallowed=$user->rights->fichinter->supprimer; + $genallowed=$user->rights->ficheinter->creer; + $delallowed=$user->rights->ficheinter->supprimer; $genallowed=1; $delallowed=0; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index e5771bd5ba8..39d133c12be 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -46,11 +46,13 @@ class Fichinter extends CommonObject var $author; var $ref; var $date; + var $date_delivery; var $duree; var $description; var $note_private; var $note_public; var $projet_id; + var $modelpdf; /** @@ -92,33 +94,34 @@ class Fichinter extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, description, duree"; - if ($this->projet_id) { - $sql .= ",fk_projet"; - } - $sql .= ") "; - $sql .= " VALUES ($this->socid, $this->date, now(), '$this->ref', $this->author, '".addslashes($this->description)."', $this->duree"; - if ($this->projet_id) { - $sql .= ", ".$this->projet_id; - } - $sql .= ")"; - $sqlok = 0; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, description, model_pdf"; + if ($this->projet_id) { + $sql .= ", fk_projet"; + } + $sql .= ") "; + $sql .= " VALUES (".$this->socid.", ".$this->date.", now(), '".$this->ref."', ".$this->author; + $sql .= ", '".addslashes($this->description)."', '".$this->modelpdf."'"; + if ($this->projet_id) { + $sql .= ", ".$this->projet_id; + } + $sql .= ")"; + $sqlok = 0; - dolibarr_syslog("Fichinter::create sql=".$sql); - $result=$this->db->query($sql); - if ($result) - { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); - $this->db->commit(); - return $this->id; - } - else - { - $this->error=$this->db->error(); - dolibarr_syslog("Fichinter::create ".$this->error); - $this->db->rollback(); - return -1; - } + dolibarr_syslog("Fichinter::create sql=".$sql); + $result=$this->db->query($sql); + if ($result) + { + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); + $this->db->commit(); + return $this->id; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("Fichinter::create ".$this->error); + $this->db->rollback(); + return -1; + } } @@ -160,8 +163,8 @@ class Fichinter extends CommonObject */ function fetch($rowid) { - $sql = "SELECT ref, description, fk_soc, fk_statut, duree"; - $sql.= ", ".$this->db->pdate(datei)." as di, fk_projet, note_public, note_private"; + $sql = "SELECT ref, description, fk_soc, fk_statut"; + $sql.= ", ".$this->db->pdate(datei)." as di, fk_projet, note_public, note_private, model_pdf"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " WHERE rowid=".$rowid; @@ -176,14 +179,16 @@ class Fichinter extends CommonObject $this->id = $rowid; $this->date = $obj->di; - $this->duree = $obj->duree; $this->ref = $obj->ref; $this->description = $obj->description; $this->socid = $obj->fk_soc; - $this->projet_id = $obj->fk_projet; + $this->projetidp = $obj->fk_projet; $this->statut = $obj->fk_statut; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; + $this->modelpdf = $obj->model_pdf; + + if ($this->statut == 0) $this->brouillon = 1; $this->db->free($resql); return 1; @@ -429,5 +434,537 @@ class Fichinter extends CommonObject dolibarr_print_error($this->db); } } -} + + /** + * \brief Classe la fiche d'intervention dans un projet + * \param project_id Id du projet dans lequel classer la facture + */ + function set_project($user, $project_id) + { + if ($user->rights->ficheinter->creer) + { + //verif que le projet et la société concordent + $sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc ='.$this->socid.' AND p.rowid='.$project_id; + $sqlres = $this->db->query($sql); + if ($sqlres) + { + $numprojet = $this->db->num_rows($sqlres); + if ($numprojet > 0) + { + $this->projetidp=$project_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinter SET fk_projet = '.$project_id; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; + $this->db->query($sql); + } + } + else + { + + dolibarr_syslog("Fichinter.class::set_project Erreur SQL"); + } + } + } + +/** + * \brief Efface fiche intervention + * \param user Objet du user qui efface + */ + function delete($user) + { + global $conf; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE fk_fichinter = ".$this->id; + if ( $this->db->query($sql) ) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter WHERE rowid = ".$this->id; + if ( $this->db->query($sql) ) + { + + // On efface le répertoire du pdf + $fichinterref = sanitize_string($this->ref); + if ($conf->fichinter->dir_output) + { + $dir = $conf->fichinter->dir_output . "/" . $fichinterref ; + $file = $conf->fichinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf"; + if (file_exists($file)) + { + fichinter_delete_preview($this->db, $this->id, $this->ref); + + if (!dol_delete_file($file)) + { + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + return 0; + } + } + if (file_exists($dir)) + { + if (!dol_delete_dir($dir)) + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + return 0; + } + } + } + + dolibarr_syslog("Suppression de la fiche intervention $this->id par $user->fullname ($user->id)"); + return 1; + } + else + { + return -2; + } + } + else + { + return -1; + } + } + +/** + * \brief Définit une date de livraison du bon d'intervention + * \param user Objet utilisateur qui modifie + * \param date_creation date de livraison + * \return int <0 si ko, >0 si ok + */ + function set_date_delivery($user, $date_delivery) + { + if ($user->rights->ficheinter->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; + $sql.= " SET datei = ".$this->db->idate($date_delivery); + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql)) + { + $this->date_delivery = $date_delivery; + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("Fichinter.class::set_date_delivery Erreur SQL"); + return -1; + } + } + } + +/** + * \brief Définit le label de l'intervention + * \param user Objet utilisateur qui modifie + * \param description description + * \return int <0 si ko, >0 si ok + */ + function set_description($user, $description) + { + if ($user->rights->ficheinter->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; + $sql.= " SET description = '".addslashes($description)."'"; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql)) + { + $this->description = $description; + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("Fichinter.class::set_description Erreur SQL"); + return -1; + } + } + } + + /** + * \brief Ajout d'une ligne d'intervention, en base + * \param fichinterid Id de la fiche d'intervention + * \param desc Description de la ligne + * \param date_intervention Date de l'intervention + * \param duration Durée de l'intervention + * \return int >0 si ok, <0 si ko + */ + function addline($fichinterid, $desc, $date_intervention, $duration) + { + dolibarr_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration"); + + if ($this->statut == 0) + { + $this->db->begin(); + + // Insertion ligne + $ligne=new FichinterLigne($this->db); + + $ligne->fk_fichinter = $fichinterid; + $ligne->desc = $desc; + $ligne->datei = $date_intervention; + $ligne->duration = $duration; + + $result=$ligne->insert(); + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("Error sql=$sql, error=".$this->error); + $this->db->rollback(); + return -1; + } + } + } + + /** + * \brief Mise à jour d'une ligne d'intervention + * \param fichinterid Id de la ligne + * \param desc Description + * \param date Date d'intervention + * \param duration Durée de l'intervention + * \return int 0 en cas de succès + */ + function updateline($fichinterid, $desc, $date_intervention, $duration) + { + dolibarr_syslog("Fichinter::UpdateLine $fichinterid, $desc, $date_intervention, $duration"); + + if ($this->statut == 0) + { + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet "; + $sql.= " SET description='".addslashes($desc)."'"; + $sql.= " , date=".$date_intervention; + $sql.= " , duree=".$duration; + $sql.= " WHERE rowid = '".$fichinterid."';"; + + $result=$this->db->query($sql); + if ($result > 0) + { + //Todo: mise à jour du total de la durée + //$this->update_price(); + $this->db->commit(); + return 0; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + dolibarr_syslog("Fichinter.class::UpdateLine Erreur sql=$sql, error=".$this->error); + return -1; + } + } + else + { + dolibarr_syslog("Fichinter.class::UpdateLigne Erreur -2 Fiche intervention en mode incompatible pour cette action"); + return -2; + } + } + + /** + * \brief Supprime une ligne d'intervention + * \param idligne Id de la ligne detail à supprimer + * \return int >0 si ok, <0 si ko + */ + function delete_line($idligne) + { + if ($this->statut == 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$idligne; + + if ($this->db->query($sql) ) + { + //Todo : faire un update du total de la durée + //$this->update_price(); + + return 1; + } + else + { + return -1; + } + } + else + { + return -2; + } + } + + /** + * \brief Stocke un numéro de rang pour toutes les lignes de + * detail d'une fiche d'intervention qui n'en ont pas. + */ + function line_order() + { + $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.'fichinterdet'; + $sql .= ' WHERE fk_fichinter='.$this->id; + $sql .= ' AND rang = 0'; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $nl = $row[0]; + } + if ($nl > 0) + { + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'fichinterdet'; + $sql .= ' WHERE fk_fichinter='.$this->id; + $sql .= ' ORDER BY rang ASC, rowid ASC'; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $this->db->fetch_row($resql); + $li[$i] = $row[0]; + $i++; + } + } + for ($i = 0 ; $i < sizeof($li) ; $i++) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinterdet SET rang = '.($i+1); + $sql .= ' WHERE rowid = '.$li[$i]; + if (!$this->db->query($sql) ) + { + dolibarr_syslog($this->db->error()); + } + } + } + } + + function line_up($rowid) + { + $this->line_order(); + + /* Lecture du rang de la ligne */ + $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.'fichinterdet'; + $sql .= ' WHERE rowid ='.$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $rang = $row[0]; + } + + if ($rang > 1 ) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinterdet SET rang = '.$rang ; + $sql .= ' WHERE fk_fichinter = '.$this->id; + $sql .= ' AND rang = '.($rang - 1); + if ($this->db->query($sql) ) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinterdet SET rang = '.($rang - 1); + $sql .= ' WHERE rowid = '.$rowid; + if (! $this->db->query($sql) ) + { + dolibarr_print_error($this->db); + } + } + else + { + dolibarr_print_error($this->db); + } + } + } + + function line_down($rowid) + { + $this->line_order(); + + /* Lecture du rang de la ligne */ + $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.'fichinterdet'; + $sql .= ' WHERE rowid ='.$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $rang = $row[0]; + } + + /* Lecture du rang max de la propale */ + $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.'fichinterdet'; + $sql .= ' WHERE fk_fichinter ='.$this->id; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $max = $row[0]; + } + + if ($rang < $max ) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinterdet SET rang = '.$rang; + $sql .= ' WHERE fk_fichinter = '.$this->id; + $sql .= ' AND rang = '.($rang+1); + if ($this->db->query($sql) ) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinterdet SET rang = '.($rang+1); + $sql .= ' WHERE rowid = '.$rowid; + if (! $this->db->query($sql) ) + { + dolibarr_print_error($this->db); + } + } + else + { + dolibarr_print_error($this->db); + } + } + } +} + + +/** + \class FichinterLigne + \brief Classe permettant la gestion des lignes d'intervention +*/ + +class FichinterLigne +{ + var $db; + var $error; + + // From llx_fichinterdet + var $rowid; + var $fk_fichinter; + var $desc; // Description ligne + var $datei; // Date intervention + var $duration; // Durée de l'intervention + var $rang = 0; + + + /** + * \brief Constructeur d'objets ligne d'intervention + * \param DB handler d'accès base de donnée + */ + function FichinterLigne($DB) + { + $this->db= $DB; + } + + /** + * \brief Recupére l'objet ligne d'intervention + * \param rowid id de la ligne + */ + function fetch($rowid) + { + $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang'; + $sql.= ', '.$db->pdate('ft.date').' as date_intervention'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; + $sql.= ' WHERE ft.rowid = '.$rowid; + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); + $this->rowid = $objp->rowid; + $this->fk_fichinter = $objp->fk_fichinter; + $this->datei = $objp->date_intervention; + $this->desc = $objp->description; + $this->duration = $objp->duree; + $this->rang = $objp->rang; + + $this->db->free($result); + } + else + { + dolibarr_print_error($this->db); + } + } + + /** + * \brief Insère l'objet ligne d'intervention en base + * \return int <0 si ko, >0 si ok + */ + function insert() + { + dolibarr_syslog("FichinterLigne.class::insert rang=".$this->rang); + $this->db->begin(); + + $rangToUse=$this->rang; + if ($rangToUse == -1) + { + // Récupère rang max de la ligne d'intervention dans $rangmax + $sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'fichinterdet'; + $sql.= ' WHERE fk_fichinter ='.$this->fk_fichinter; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $rangToUse = $obj->max + 1; + } + else + { + dolibarr_print_error($this->db); + $this->db->rollback(); + return -1; + } + } + + // Insertion dans base de la ligne + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'fichinterdet'; + $sql.= ' (fk_fichinter, description, date, duree, rang)'; + $sql.= " VALUES (".$this->fk_fichinter.","; + $sql.= " '".addslashes($this->desc)."',"; + $sql.= " ".$this->datei.","; + $sql.= " ".$this->duration.","; + $sql.= ' '.$rangToUse; + $sql.= ')'; + + dolibarr_syslog("fichinterLigne.class::insert sql=$sql"); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->rang=$rangToUse; + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + dolibarr_syslog("FichinterLigne::insert Error ".$this->error); + $this->db->rollback(); + return -1; + } + } + + + /** + * \brief Mise a jour de l'objet ligne d'intervention en base + * \return int <0 si ko, >0 si ok + */ + function update() + { + $this->db->begin(); + + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet SET"; + $sql.= " description='".addslashes($this->desc)."'"; + $sql.= ",date=".$this->datei; + $sql.= ",duree=".$this->duration; + $sql.= ",rang='".$this->rang."'"; + $sql.= " WHERE rowid = ".$this->rowid; + + dolibarr_syslog("FichinterLigne::update sql=$sql"); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("FichinterLigne::update Error ".$this->error); + $this->db->rollback(); + return -2; + } + } + +} + + ?> \ No newline at end of file diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index abdb1f13e36..5ea1cc4a948 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2763,24 +2763,35 @@ class Form /** \brief Fonction servant a afficher une durée dans une liste déroulante - \param prefix prefix + \param prefix prefix + \param iSecond Nombre de secondes */ - function select_duree($prefix) + function select_duree($prefix,$iSecond='') { + if ($iSecond) + { + $hourSelected = ConvertSecondToTime($iSecond,'hour'); + $minSelected = ConvertSecondToTime($iSecond,'min'); + } print '"; print "H  "; print '"; print "M "; diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index 4220437c66c..022d9d4ce66 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -341,7 +341,7 @@ class MenuLeft { { $langs->load("interventions"); $newmenu->add(DOL_URL_ROOT."/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire); - if ($leftmenu=="ficheinter") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer); + if ($leftmenu=="ficheinter") $newmenu->add_submenu(DOL_URL_ROOT."/fichinter/fiche.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer); if ($leftmenu=="ficheinter") $newmenu->add_submenu(DOL_URL_ROOT."/fichinter/index.php?leftmenu=ficheinter", $langs->trans("List"), 1 ,$user->rights->ficheinter->lire); } diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 8ad0189b11f..2d1bf02c662 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -195,4 +195,54 @@ function fichinter_pdf_create($db, $id, $modele='', $outputlangs='') } } +/** + \brief Supprime l'image de prévisualitation, pour le cas de régénération de propal + \param db objet base de donnée + \param propalid id de la propal à effacer + \param propalref référence de la propal si besoin +*/ +function fichinter_delete_preview($db, $fichinterid, $fichinterref='') +{ + global $langs,$conf; + + if (!$fichinterref) + { + $fichinter = new Fichinter($db,"",$fichinterid); + $fichinter->fetch($fichinterid); + $fichinterref = $fichinter->ref; + } + + if ($conf->fichinter->dir_output) + { + $fichinterref = sanitize_string($fichinterref); + $dir = $conf->fichinter->dir_output . "/" . $fichinterref ; + $file = $dir . "/" . $fichinterref . ".pdf.png"; + $multiple = $file . "."; + + if ( file_exists( $file ) && is_writable( $file ) ) + { + if ( ! unlink($file) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$file); + return 0; + } + } + else + { + for ($i = 0; $i < 20; $i++) + { + $preview = $multiple.$i; + if ( file_exists( $preview ) && is_writable( $preview ) ) + { + if ( ! unlink($preview) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); + return 0; + } + } + } + } + } +} + ?> diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index f798325438b..0e9e49e8aff 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -227,7 +227,7 @@ function propale_delete_preview($db, $propalid, $propalref='') if ($conf->propal->dir_output) { - $propref = sanitize_string($propalref); + $propalref = sanitize_string($propalref); $dir = $conf->propal->dir_output . "/" . $propalref ; $file = $dir . "/" . $propalref . ".pdf.png"; $multiple = $file . "."; diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 855da8ad9fb..0587d1a419f 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -11,6 +11,12 @@ AllInterventions=All interventions CreateDaftIntervention=Create draft CustomerDoesNotHavePrefix=Customer does not have a prefix InterventionContact=Intervention contact +DeleteIntervention=Delete intervention +ValidateIntervention=Validate intervention +DeleteInterventionLine=Delete intervention line +ConfirmDeleteIntervention=Are you sure you want to delete this intervention ? +ConfirmValidateIntervention=Are you sure you want to validate this intervention ? +ConfirmDeleteInterventionLine=Are you sure you want to delete this intervention line ? ##### Types de contacts ##### TypeContact_fichinter_internal_INTERREPFOLL=Representative following-up intervention TypeContact_fichinter_internal_INTERVENING=Intervening diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 55d9ec4e59a..1cbd8d74804 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -249,6 +249,7 @@ ChartNotGenerated=Chart not generated GeneratedOn=Build on %s Generate=Generate Duration=Duration +TotalDuration=Total duration Summary=Summary MyBookmarks=My bookmarks OtherInformationsBoxes=Other information boxes diff --git a/htdocs/langs/fr_FR/interventions.lang b/htdocs/langs/fr_FR/interventions.lang index 40d0e08b539..8c18db63704 100644 --- a/htdocs/langs/fr_FR/interventions.lang +++ b/htdocs/langs/fr_FR/interventions.lang @@ -11,6 +11,12 @@ AllInterventions=Toutes les interventions CreateDaftIntervention=Créer brouillon CustomerDoesNotHavePrefix=Le client n'a pas de préfixe de défini InterventionContact=Contact intervention +DeleteIntervention=Supprimer intervention +ValidateIntervention=Valider intervention +DeleteInterventionLine=Supprimer ligne d'intervention +ConfirmDeleteIntervention=Êtes-vous sûr de vouloir effacer cette intervention ? +ConfirmValidateIntervention=Êtes-vous sûr de vouloir valider cette intervention ? +ConfirmDeleteInterventionLine=Êtes-vous sûr de vouloir effacer cette ligne ? ##### Types de contacts ##### TypeContact_fichinter_internal_INTERREPFOLL=Responsable suivi de l'intervention TypeContact_fichinter_internal_INTERVENING=Intervenant diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 1bcd3c5db10..004b0b12a75 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -250,6 +250,7 @@ ChartNotGenerated=Graphique non g GeneratedOn=Généré le %s Generate=Générer Duration=Durée +TotalDuration=Durée totale Summary=Résumé MyBookmarks=Mes marques pages OtherInformationsBoxes=Autres boîtes d'informations diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php index b74a603a083..6912123f21a 100644 --- a/htdocs/lib/fichinter.lib.php +++ b/htdocs/lib/fichinter.lib.php @@ -48,6 +48,14 @@ function fichinter_prepare_head($fichinter) $head[$h][2] = 'contact'; $h++; + if ($conf->use_preview_tabs) + { + $head[$h][0] = DOL_URL_ROOT.'/fichinter/apercu.php?id='.$fichinter->id; + $head[$h][1] = $langs->trans('Preview'); + $head[$h][2] = 'preview'; + $h++; + } + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$fichinter->id; $head[$h][1] = $langs->trans('Note'); $head[$h][2] = 'note'; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 2f601fcef13..51847336473 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -3121,4 +3121,35 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ return $imgThumbName; } +/* + * \brief Converti les heures et minutes en secondes + * \param iHours Heures + * \param iMinutes Minutes + * \param iSeconds Secondes + * \return iResult Temps en secondes + */ +function ConvertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0) +{ + $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; + return $iResult; +} + +/* + * \brief Converti les secondes en heures et minutes + * \param iSecond Nombre de secondes + * \param format Choix de l'affichage (all:affichage complet, hour: n'affiche que les heures, min: n'affiche que les minutes) + * \return sTime Temps formaté + */ +function ConvertSecondToTime($iSecond,$format='all'){ + if ($format == 'all'){ + $sTime=date("H",$iSecond)-1; + $sTime.='h'.date("i",$iSecond); + }else if ($format == 'hour'){ + $sTime=date("H",$iSecond)-1; + }else if ($format == 'min'){ + $sTime=date("i",$iSecond); + } + return $sTime; +} + ?> diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 25a9a74c0f6..d54660a7793 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2006 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -315,7 +316,7 @@ class Project extends CommonObject } /* - * \brief Supprime l'projet dans la base + * \brief Supprime le projet dans la base * \param Utilisateur */ @@ -363,7 +364,7 @@ class Project extends CommonObject $result = -2; } - if ($result ==0) + if ($result == 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user) "; diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index a95bf4a46f8..32fb10604a6 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -151,23 +152,23 @@ Function PLineSelect(&$inc, $parent, $lines, &$level) if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) { - $pro = new Project($db); + $project = new Project($db); - $result = $pro->fetch($_GET["id"]); + $result = $project->fetch($_GET["id"]); if ($result == 0) - { + { + $task_parent = $_POST["task_parent"]?$_POST["task_parent"]:0; + $project->CreateTask($user, $_POST["task_name"], $task_parent); - $pro->CreateTask($user, $_POST["task_name"], $_POST["task_parent"]); - - Header("Location:fiche.php?id=".$pro->id); - } + Header("Location:fiche.php?id=".$project->id); + } } if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) { - $pro = new Project($db); - $result = $pro->fetch($_GET["id"]); + $project = new Project($db); + $result = $project->fetch($_GET["id"]); if ($result == 0) { @@ -181,12 +182,12 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) $id = ereg_replace("task","",$key); $date = mktime(12,12,12,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]); - $pro->TaskAddTime($user, $id , $post, $date); + $project->TaskAddTime($user, $id , $post, $date); } } } - Header("Location:fiche.php?id=".$pro->id); + Header("Location:fiche.php?id=".$project->id); exit; } } @@ -253,11 +254,14 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) /* Nouvelle tâche */ print '
'.$langs->trans("NewTask").''; print ' '; - print ' '; - print ''; + if ($tasksarray) + { + print ''; + } + print ' '; print '

'; diff --git a/mysql/data/data.sql b/mysql/data/data.sql index ba719b55652..121e589faff 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -1219,7 +1219,7 @@ insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titr insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1406, 'commercial', '$leftmenu=="contracts"', 1402, '/contrat/services.php?leftmenu=contracts&mode=4&filter=expired', 'MenuExpiredServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 2); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1407, 'commercial', '$leftmenu=="contracts"', 1402, '/contrat/services.php?leftmenu=contracts&mode=5', 'MenuClosedServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 3); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1500, 'commercial', '', 5, '/fichinter/index.php?leftmenu=ficheinter', 'Interventions', 0, 'interventions', '$user->rights->ficheinter->lire', '', 2, 8); -insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1501, 'commercial', '$leftmenu=="ficheinter"', 1500, '/societe.php?leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0); +insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1501, 'commercial', '$leftmenu=="ficheinter"', 1500, '/fichinter/fiche.php?action=create&leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1502, 'commercial', '$leftmenu=="ficheinter"', 1500, '/fichinter/index.php?leftmenu=ficheinter', 'List', 1, 'interventions', '$user->rights->ficheinter->lire', '', 2, 1); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1600, 'accountancy', '', 6, '/compta/index.php?leftmenu=suppliers', 'Suppliers', 0, 'companies', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 0); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1601, 'accountancy', '', 1600, '/soc.php?leftmenu=suppliers&action=create&type=f', 'NewSupplier', 1, 'companies', '$user->rights->societe->creer && $user->rights->fournisseur->lire', '', 2, 0); diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 18f571feac5..52703aac624 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -247,7 +247,7 @@ insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titr insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1406, 'commercial', '$leftmenu=="contracts"', 1402, '/contrat/services.php?leftmenu=contracts&mode=4&filter=expired', 'MenuExpiredServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 2); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1407, 'commercial', '$leftmenu=="contracts"', 1402, '/contrat/services.php?leftmenu=contracts&mode=5', 'MenuClosedServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 3); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1500, 'commercial', '', 5, '/fichinter/index.php?leftmenu=ficheinter', 'Interventions', 0, 'interventions', '$user->rights->ficheinter->lire', '', 2, 8); -insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1501, 'commercial', '$leftmenu=="ficheinter"', 1500, '/societe.php?leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0); +insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1501, 'commercial', '$leftmenu=="ficheinter"', 1500, '/fichinter/fiche.php?action=create&leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1502, 'commercial', '$leftmenu=="ficheinter"', 1500, '/fichinter/index.php?leftmenu=ficheinter', 'List', 1, 'interventions', '$user->rights->ficheinter->lire', '', 2, 1); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1600, 'accountancy', '', 6, '/compta/index.php?leftmenu=suppliers', 'Suppliers', 0, 'companies', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 0); insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1601, 'accountancy', '', 1600, '/soc.php?leftmenu=suppliers&action=create&type=f', 'NewSupplier', 1, 'companies', '$user->rights->societe->creer && $user->rights->fournisseur->lire', '', 2, 0); @@ -821,6 +821,17 @@ alter table llx_boxes modify box_order varchar(3) NOT NULL; -- V4.1 update llx_boxes set box_order = concat('A',box_order) where length(box_order) = 2 and substring(box_order,-1) in ('1','3','5','7','9'); -- V4.1 update llx_boxes set box_order = concat('B',box_order) where length(box_order) = 2 and substring(box_order,-1) in ('0','2','4','6','8'); +create table llx_fichinterdet +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_fichinter integer, + date date, + description text, + duree integer, + rang integer DEFAULT 0 +)type=innodb; + +ALTER TABLE llx_fichinter ADD COLUMN model_pdf varchar(50) after note_public; alter table llx_bordereau_cheque modify number integer; -ALTER TABLE llx_facturedet ADD COLUMN special_code tinyint(4) default 0; \ No newline at end of file +ALTER TABLE llx_facturedet ADD COLUMN special_code tinyint(4) default 0; diff --git a/mysql/tables/llx_fichinter.sql b/mysql/tables/llx_fichinter.sql index 5289f2e03f2..370aeebdda1 100644 --- a/mysql/tables/llx_fichinter.sql +++ b/mysql/tables/llx_fichinter.sql @@ -30,14 +30,15 @@ create table llx_fichinter tms timestamp, datec datetime, -- date de creation date_valid datetime, -- date de validation - datei date, -- date de l'intervention + datei date, -- date de livraison du bon d'intervention fk_user_author integer, -- createur de la fiche fk_user_valid integer, -- valideur de la fiche fk_statut smallint DEFAULT 0, - duree real, + duree real, -- durée totale de l'intervention description text, note_private text, note_public text, + model_pdf varchar(50), UNIQUE INDEX (ref) )type=innodb; diff --git a/mysql/tables/llx_fichinterdet.sql b/mysql/tables/llx_fichinterdet.sql new file mode 100644 index 00000000000..5155564a354 --- /dev/null +++ b/mysql/tables/llx_fichinterdet.sql @@ -0,0 +1,31 @@ +-- =================================================================== +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2005-2007 Regis Houssin +-- +-- 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 +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- $Source$ +-- =================================================================== + +create table llx_fichinterdet +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_fichinter integer, + date date, -- date de la ligne d'intervention + description text, -- description de la ligne d'intervention + duree integer, -- duree de la ligne d'intervention + rang integer DEFAULT 0 -- ordre affichage sur la fiche +)type=innodb;