diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 8a63be13a91..a154b668bbf 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -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 diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 0864ceb1379..3b2bb016415 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * 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='
'.$fichinter->error.'
'; + } } 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 "
"; - - $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 ""; + + $smonth = 1; + $syear = date("Y", time()); print ''; print ''; @@ -166,7 +192,7 @@ if ($_GET["action"] == 'create') print ""; print "\n"; - + print "\n"; if ($conf->projet->enabled) @@ -204,31 +230,31 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("Add").''; } } - + } print ''; - + print ''; print "'; print ''; - + print '
".$langs->trans("Ref")."
".$langs->trans("Duration")." (".$langs->trans("days").")
'.$langs->trans("Description").'"; 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 ''; - } + } print '
'; print ''; print '
'; print '
'; } @@ -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 "
"; @@ -306,10 +333,6 @@ elseif ($_GET["id"] > 0) /* * Affichage en mode visu */ - if ($mesg) print $mesg."
"; - - - $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."
"; + + $head = fichinter_prepare_head($fichinter); + + dolibarr_fiche_head($head, 'card', $langs->trans("InterventionCard")); + print ''; @@ -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 "
\n"; } -else -{ - Header("Location: index.php"); -} $db->close(); diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index d295c325c63..be420f206d5 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -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; + } + } + } } ?> \ No newline at end of file diff --git a/htdocs/includes/modules/modFicheinter.class.php b/htdocs/includes/modules/modFicheinter.class.php index e959753eaac..af01411665f 100644 --- a/htdocs/includes/modules/modFicheinter.class.php +++ b/htdocs/includes/modules/modFicheinter.class.php @@ -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); } /** diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 25cef37b66f..df7617c9690 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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 diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0e722ba5f75..9bbade30ba0 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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 diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php new file mode 100644 index 00000000000..09d7b4726e7 --- /dev/null +++ b/htdocs/lib/fichinter.lib.php @@ -0,0 +1,52 @@ + + * Copyright (C) 2007 Rodolphe Quiedeville + * + * 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; +} + +?>