Uniformisation du code de gestion des fiche intervention
This commit is contained in:
parent
132ee0d9fb
commit
4b7b8d0dbc
@ -35,11 +35,6 @@ require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
|
||||
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php');
|
||||
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
|
||||
|
||||
$user->getrights('facture');
|
||||
$user->getrights('propale');
|
||||
if (!$user->rights->propale->lire)
|
||||
accessforbidden();
|
||||
|
||||
$langs->load('companies');
|
||||
$langs->load('compta');
|
||||
$langs->load('orders');
|
||||
@ -57,6 +52,9 @@ $pagenext = $page + 1;
|
||||
|
||||
|
||||
// Sécurité accés client
|
||||
$user->getrights('facture');
|
||||
$user->getrights('propale');
|
||||
if (!$user->rights->propale->lire) accessforbidden();
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
@ -64,6 +62,19 @@ if ($user->societe_id > 0)
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
if ($_GET['propalid'] > 0)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$result=$propal->fetch($_GET['propalid']);
|
||||
if (! $result > 0)
|
||||
{
|
||||
dolibarr_print_error($db,$propal->error);
|
||||
exit;
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && $user->societe_id > 0 && $propal->socid <> $user->societe_id)
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
@ -107,7 +118,7 @@ if ( $action == 'delete' )
|
||||
|
||||
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
@ -123,11 +134,6 @@ if ($_GET["propalid"] > 0)
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
|
||||
if ($user->societe_id > 0 && $propal->socid <> $user->societe_id)
|
||||
accessforbidden();
|
||||
|
||||
llxHeader();
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
@ -721,8 +727,6 @@ et non globalement
|
||||
|
||||
} else {
|
||||
|
||||
llxHeader();
|
||||
|
||||
/**
|
||||
*
|
||||
* Mode Liste des propales
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -31,6 +31,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/project.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.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");
|
||||
@ -45,21 +46,37 @@ 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;
|
||||
}
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$fichinter = new Fichinter($db);
|
||||
$result=$fichinter->fetch($_GET["id"]);
|
||||
if (! $result > 0)
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
exit;
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && $user->societe_id > 0 && $fichinter->socid <> $user->societe_id) accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Traitements des actions
|
||||
*/
|
||||
if ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && ! $_REQUEST["id"] > 0)
|
||||
{
|
||||
Header("Location: index.php");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'valid')
|
||||
{
|
||||
@ -71,18 +88,25 @@ if ($_GET["action"] == 'valid')
|
||||
|
||||
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(dolibarr_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"];
|
||||
|
||||
$result = $fichinter->create();
|
||||
if ($result > 0)
|
||||
{
|
||||
$_GET["id"]=$result; // Force raffraichissement sur fiche venant d'etre créée
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$fichinter->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'update')
|
||||
@ -119,40 +143,42 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
$html = new Form($db);
|
||||
|
||||
/*
|
||||
*
|
||||
* Mode creation
|
||||
* Creation d'une nouvelle fiche d'intervention
|
||||
*
|
||||
*/
|
||||
llxHeader();
|
||||
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
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 "<form name='fichinter' action=\"fiche.php\" method=\"post\">";
|
||||
|
||||
$smonth = 1;
|
||||
$syear = date("Y", time());
|
||||
/*
|
||||
* Mode creation
|
||||
* Creation d'une nouvelle fiche d'intervention
|
||||
*/
|
||||
|
||||
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 "<form name='fichinter' action=\"fiche.php\" method=\"post\">";
|
||||
|
||||
$smonth = 1;
|
||||
$syear = date("Y", time());
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="socid" value='.$_GET["socid"].'>';
|
||||
@ -166,7 +192,7 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
print "<tr><td>".$langs->trans("Ref")."</td>";
|
||||
print "<td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
|
||||
|
||||
|
||||
print "<tr><td>".$langs->trans("Duration")." (".$langs->trans("days").")</td><td><input name=\"duree\"></td></tr>\n";
|
||||
|
||||
if ($conf->projet->enabled)
|
||||
@ -204,31 +230,31 @@ if ($_GET["action"] == 'create')
|
||||
print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socid='.$socid.'&action=create>'.$langs->trans("Add").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
|
||||
print "<td>";
|
||||
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE)
|
||||
{
|
||||
// Editeur wysiwyg
|
||||
{
|
||||
// Editeur wysiwyg
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
$doleditor=new DolEditor('note','',280,'dolibarr_notes','In',true);
|
||||
$doleditor->Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<textarea name="note" wrap="soft" cols="70" rows="15"></textarea>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("CreateDaftIntervention").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
@ -240,12 +266,13 @@ elseif ($_GET["action"] == 'edit' && $_GET["id"] > 0)
|
||||
* 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"));
|
||||
$head = fichinter_prepare_head($fichinter);
|
||||
|
||||
dolibarr_fiche_head($head, 'card', $langs->trans("EditIntervention"));
|
||||
|
||||
|
||||
print "<form name='update' action=\"fiche.php\" method=\"post\">";
|
||||
@ -306,10 +333,6 @@ elseif ($_GET["id"] > 0)
|
||||
/*
|
||||
* Affichage en mode visu
|
||||
*/
|
||||
if ($mesg) print $mesg."<br>";
|
||||
|
||||
|
||||
|
||||
$fichinter = new Fichinter($db);
|
||||
$result=$fichinter->fetch($_GET["id"]);
|
||||
if (! $result > 0)
|
||||
@ -317,14 +340,14 @@ elseif ($_GET["id"] > 0)
|
||||
dolibarr_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($user->societe_id > 0 && $fichinter->socid <> $user->societe_id)
|
||||
accessforbidden();
|
||||
|
||||
llxHeader();
|
||||
dolibarr_fiche_head($head, $a, $langs->trans("InterventionCard"));
|
||||
|
||||
$fichinter->fetch_client();
|
||||
|
||||
if ($mesg) print $mesg."<br>";
|
||||
|
||||
$head = fichinter_prepare_head($fichinter);
|
||||
|
||||
dolibarr_fiche_head($head, 'card', $langs->trans("InterventionCard"));
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -387,8 +410,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->fichinter->creer;
|
||||
$delallowed=$user->rights->fichinter->supprimer;
|
||||
$genallowed=1;
|
||||
$delallowed=0;
|
||||
|
||||
@ -402,10 +425,6 @@ elseif ($_GET["id"] > 0)
|
||||
print "</tr></table>\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: index.php");
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -80,6 +80,8 @@ class Fichinter extends CommonObject
|
||||
{
|
||||
if (! is_numeric($this->duree)) { $this->duree = 0; }
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree";
|
||||
if ($this->projet_id) {
|
||||
$sql .= ",fk_projet";
|
||||
@ -87,19 +89,25 @@ class Fichinter extends CommonObject
|
||||
$sql .= ") ";
|
||||
$sql .= " VALUES ($this->socid, $this->date, now(), '$this->ref', $this->author, '".addslashes($this->note)."', $this->duree";
|
||||
if ($this->projet_id) {
|
||||
$sql .= ", $this->projet_id";
|
||||
$sql .= ", ".$this->projet_id;
|
||||
}
|
||||
$sql .= ")";
|
||||
$sqlok = 0;
|
||||
|
||||
dolibarr_syslog("Fichinter::create sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
|
||||
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Fichinter::create ".$this->error);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
@ -289,5 +297,31 @@ class Fichinter extends CommonObject
|
||||
if ($statut==1) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut1');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Positionne modele derniere generation
|
||||
* \param user Objet use qui modifie
|
||||
* \param modelpdf Nom du modele
|
||||
*/
|
||||
function set_pdf_model($user, $modelpdf)
|
||||
{
|
||||
if ($user->rights->facture->creer)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET model_pdf = '$modelpdf'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->modelpdf=$modelpdf;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -76,6 +76,17 @@ class modFicheinter extends DolibarrModules
|
||||
|
||||
// Constantes
|
||||
$this->const = array();
|
||||
$r=0;
|
||||
|
||||
$this->const[$r][0] = "FICHINTER_ADDON_PDF";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "soleil";
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "FICHINTER_ADDON";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "pacific";
|
||||
$r++;
|
||||
|
||||
// Boites
|
||||
$this->boxes = array();
|
||||
@ -111,10 +122,20 @@ class modFicheinter extends DolibarrModules
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
// Permissions
|
||||
$this->remove();
|
||||
|
||||
return $this->_init($sql);
|
||||
global $conf;
|
||||
|
||||
// Permissions
|
||||
$this->remove();
|
||||
|
||||
// Dir
|
||||
$this->dirs[0] = $conf->facture->dir_output;
|
||||
|
||||
$sql = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."'",
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type) VALUES('".$this->const[0][2]."','ficheinter')",
|
||||
);
|
||||
|
||||
return $this->_init($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -488,6 +488,7 @@ OrdersNumberingModules=Orders numbering modules
|
||||
OrdersModelModule=Order documents models
|
||||
HideTreadedOrders=Hide the treated orders in the list
|
||||
##### Fiche inter #####
|
||||
FicheinterNumberingModules=Intervention numbering modules
|
||||
TemplatePDFInterventions=Intervention card documents models
|
||||
##### Clicktodial #####
|
||||
ClickToDialSetup=Click To Dial module setup
|
||||
|
||||
@ -487,6 +487,7 @@ OrdersNumberingModules=Modules de num
|
||||
OrdersModelModule=Modèles de document des commandes
|
||||
HideTreadedOrders=Cacher les commandes traitées de la liste
|
||||
##### Fiche inter #####
|
||||
FicheinterNumberingModules=Modules de numérotation des fiches interventions
|
||||
TemplatePDFInterventions=Modèle de documents des fiches d'interventions
|
||||
##### Clicktodial #####
|
||||
ClickToDialSetup=Configuration du module Click To Dial
|
||||
|
||||
52
htdocs/lib/fichinter.lib.php
Normal file
52
htdocs/lib/fichinter.lib.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/fichinter.lib.php
|
||||
\brief Ensemble de fonctions de base pour le module fichinter
|
||||
\ingroup fichinter
|
||||
\version $Revision$
|
||||
|
||||
Ensemble de fonctions de base de dolibarr sous forme d'include
|
||||
*/
|
||||
|
||||
function fichinter_prepare_head($fichinter)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
$langs->load("fichinter");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
if ($conf->fichinter->enabled && $user->rights->ficheinter->lire)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$fichinter->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
}
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user