New: Ajout module numrotation pour les fiche interventions
This commit is contained in:
parent
96e849986b
commit
b064e4c272
@ -99,8 +99,6 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$_GET["value"]))
|
||||
{
|
||||
// La constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->COMMANDE_ADDON_PDF = $_GET["value"];
|
||||
}
|
||||
|
||||
@ -126,13 +124,7 @@ if ($_GET["action"] == 'setmod')
|
||||
// \todo Verifier si module numerotation choisi peut etre activé
|
||||
// par appel methode canBeActivated
|
||||
|
||||
|
||||
if (dolibarr_set_const($db, "COMMANDE_ADDON",$_GET["value"]))
|
||||
{
|
||||
// la constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->COMMANDE_ADDON = $_GET["value"];
|
||||
}
|
||||
dolibarr_set_const($db, "COMMANDE_ADDON",$_GET["value"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -73,8 +73,6 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$_GET["value"]))
|
||||
{
|
||||
// La constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->EXPEDITION_ADDON_PDF = $_GET["value"];
|
||||
}
|
||||
|
||||
@ -119,13 +117,7 @@ if ($_GET["action"] == 'setmod')
|
||||
// \todo Verifier si module numerotation choisi peut etre activé
|
||||
// par appel methode canBeActivated
|
||||
|
||||
|
||||
if (dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["value"]))
|
||||
{
|
||||
// la constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->EXPEDITION_ADDON = $_GET["value"];
|
||||
}
|
||||
dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["value"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -99,8 +99,6 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"]))
|
||||
{
|
||||
// La constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->FACTURE_ADDON_PDF = $_GET["value"];
|
||||
}
|
||||
|
||||
|
||||
@ -93,6 +93,15 @@ if ($_GET["action"] == 'setdoc')
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'setmod')
|
||||
{
|
||||
// \todo Verifier si module numerotation choisi peut etre activé
|
||||
// par appel methode canBeActivated
|
||||
|
||||
dolibarr_set_const($db, "FICHEINTER_ADDON",$_GET["value"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
@ -100,13 +109,82 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
llxHeader();
|
||||
|
||||
$dir = "../includes/modules/fichinter/";
|
||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules/fichinter/";
|
||||
$html=new Form($db);
|
||||
|
||||
print_titre($langs->trans("InterventionsSetup"));
|
||||
|
||||
print "<br>";
|
||||
|
||||
|
||||
print_titre($langs->trans("FicheinterNumberingModules"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="100">'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td>'.$langs->trans("Example").'</td>';
|
||||
print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
|
||||
print '<td align="center" width="16">'.$langs->trans("Info").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$handle = opendir($dir);
|
||||
if ($handle)
|
||||
{
|
||||
$var=true;
|
||||
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi('^(mod_.*)\.php$',$file,$reg))
|
||||
{
|
||||
$file = $reg[1];
|
||||
|
||||
require_once($dir.$file.".php");
|
||||
|
||||
$module = new $file;
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
|
||||
print $module->info();
|
||||
print '</td>';
|
||||
|
||||
// Examples
|
||||
print '<td nowrap="nowrap">'.$module->getExample()."</td>\n";
|
||||
|
||||
print '<td align="center">';
|
||||
if ("mod_".$conf->global->FICHEINTER_ADDON == $file)
|
||||
{
|
||||
print img_tick($langs->trans("Activated"));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.$file.'" alt="'.$langs->trans("Default").'">'.$langs->trans("Activate").'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$nextval=$module->getNextValue();
|
||||
if ($nextval != $langs->trans("NotAvailable"))
|
||||
{
|
||||
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;
|
||||
}
|
||||
print '<td align="center" '.$html->tooltip_properties($htmltooltip).'>';
|
||||
print ($htmltooltip?img_help(0):'');
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
|
||||
print_titre($langs->trans("TemplatePDFInterventions"));
|
||||
|
||||
// Defini tableau def des modeles
|
||||
|
||||
@ -73,8 +73,6 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$_GET["value"]))
|
||||
{
|
||||
// La constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $_GET["value"];
|
||||
}
|
||||
|
||||
@ -100,13 +98,7 @@ if ($_GET["action"] == 'setmod')
|
||||
// \todo Verifier si module numerotation choisi peut etre activé
|
||||
// par appel methode canBeActivated
|
||||
|
||||
|
||||
if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$_GET["value"]))
|
||||
{
|
||||
// la constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->COMMANDE_SUPPLIER_ADDON = $_GET["value"];
|
||||
}
|
||||
dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$_GET["value"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -73,8 +73,6 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$_GET["value"]))
|
||||
{
|
||||
// La constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->LIVRAISON_ADDON_PDF = $_GET["value"];
|
||||
}
|
||||
|
||||
@ -100,13 +98,7 @@ if ($_GET["action"] == 'setmod')
|
||||
// \todo Verifier si module numerotation choisi peut etre activé
|
||||
// par appel methode canBeActivated
|
||||
|
||||
|
||||
if (dolibarr_set_const($db, "LIVRAISON_ADDON",$_GET["value"]))
|
||||
{
|
||||
// la constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->LIVRAISON_ADDON = $_GET["value"];
|
||||
}
|
||||
dolibarr_set_const($db, "LIVRAISON_ADDON",$_GET["value"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -118,8 +118,6 @@ if ($_GET["action"] == 'setdoc')
|
||||
|
||||
if (dolibarr_set_const($db, "PROPALE_ADDON_PDF",$_GET["value"]))
|
||||
{
|
||||
// La constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->PROPALE_ADDON_PDF = $_GET["value"];
|
||||
}
|
||||
|
||||
@ -145,13 +143,7 @@ if ($_GET["action"] == 'setmod')
|
||||
// \todo Verifier si module numerotation choisi peut etre activé
|
||||
// par appel methode canBeActivated
|
||||
|
||||
|
||||
if (dolibarr_set_const($db, "PROPALE_ADDON",$_GET["value"]))
|
||||
{
|
||||
// la constante qui a été lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage cohérent
|
||||
$conf->global->PROPALE_ADDON = $_GET["value"];
|
||||
}
|
||||
dolibarr_set_const($db, "PROPALE_ADDON",$_GET["value"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -31,9 +31,9 @@ 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");
|
||||
if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php"))
|
||||
if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php"))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php");
|
||||
}
|
||||
|
||||
$langs->load("companies");
|
||||
@ -138,18 +138,20 @@ if ($_GET["action"] == 'create')
|
||||
{
|
||||
print_titre($langs->trans("AddIntervention"));
|
||||
|
||||
// \todo Utiliser un module de numérotation
|
||||
|
||||
if (! $conf->global->FICHEINTER_ADDON)
|
||||
{
|
||||
dolibarr_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
|
||||
exit;
|
||||
}
|
||||
|
||||
$fix = new Fichinter($db);
|
||||
|
||||
$obj = $conf->global->FICHEINTER_ADDON;
|
||||
$file = "mod_".$conf->global->FICHEINTER_ADDON.".php";
|
||||
|
||||
// \todo Quand module numerotation fiche inter sera dispo
|
||||
// $modFicheinter = new $obj;
|
||||
// $numpr = $modFicheinter->getNextValue($soc);
|
||||
$obj = "mod_".$conf->global->FICHEINTER_ADDON;
|
||||
$modFicheinter = new $obj;
|
||||
$numpr = $modFicheinter->getNextValue($societe);
|
||||
|
||||
$numpr = $fix->get_new_num($societe);
|
||||
|
||||
print "<form name='fichinter' action=\"fiche.php\" method=\"post\">";
|
||||
|
||||
@ -167,16 +169,7 @@ if ($_GET["action"] == 'create')
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
||||
|
||||
print "<tr><td>".$langs->trans("Ref")."</td>";
|
||||
|
||||
// en attendant le module de numérotation
|
||||
if ($societe->prefix_comm)
|
||||
{
|
||||
print "<td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".img_warning().$langs->trans("CustomerDoesNotHavePrefix")."</td></tr>\n";
|
||||
}
|
||||
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";
|
||||
|
||||
@ -223,13 +216,9 @@ if ($_GET["action"] == 'create')
|
||||
print "<td><textarea name=\"note\" wrap=\"soft\" cols=\"60\" rows=\"15\"></textarea>";
|
||||
print '</td></tr>';
|
||||
|
||||
// en attendant le module de numérotation
|
||||
if ($societe->prefix_comm)
|
||||
{
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("CreateDaftIntervention").'">';
|
||||
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>';
|
||||
@ -410,5 +399,6 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
}
|
||||
|
||||
$db->close();
|
||||
llxFooter();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -39,12 +39,12 @@ include_once("modules_commande.php");
|
||||
class mod_commande_ivoire extends ModeleNumRefCommandes
|
||||
{
|
||||
|
||||
/** \brief Constructeur
|
||||
*/
|
||||
function mod_commande_ivoire()
|
||||
{
|
||||
$this->nom = "Ivoire";
|
||||
}
|
||||
/** \brief Constructeur
|
||||
*/
|
||||
function mod_commande_ivoire()
|
||||
{
|
||||
$this->nom = "Ivoire";
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi la description du modele de numérotation
|
||||
|
||||
156
htdocs/includes/modules/fichinter/mod_pacific.php
Normal file
156
htdocs/includes/modules/fichinter/mod_pacific.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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/includes/modules/fichinter/mod_pacific.php
|
||||
\ingroup facture
|
||||
\brief Fichier contenant la classe du modèle de numérotation de référence de fiche intervention Pacific
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/modules_fichinter.php");
|
||||
|
||||
/** \class mod_facture_terre
|
||||
\brief Classe du modèle de numérotation de référence de fiche intervention Pacific
|
||||
*/
|
||||
|
||||
class mod_pacific extends ModeleNumRefFicheinter
|
||||
{
|
||||
var $prefix='FI';
|
||||
var $error='';
|
||||
|
||||
|
||||
/** \brief Constructeur
|
||||
*/
|
||||
function mod_pacific()
|
||||
{
|
||||
$this->nom = "pacific";
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi la description du modele de numérotation
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function info()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
return $langs->trans('PacificNumRefModelDesc1',$this->prefix);
|
||||
}
|
||||
|
||||
/** \brief Renvoi un exemple de numérotation
|
||||
* \return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
return $this->prefix."0501-0001";
|
||||
}
|
||||
|
||||
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numérotation de fonctionner.
|
||||
* \return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
$fayymm='';
|
||||
|
||||
$sql = "SELECT MAX(ref)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) $fayymm = substr($row[0],0,6);
|
||||
}
|
||||
if (! $fayymm || eregi($this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans('PacificNumRefModelError');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribuée
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
|
||||
$fayymm='';
|
||||
$sql = "SELECT MAX(ref)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) $fayymm = substr($row[0],0,6);
|
||||
}
|
||||
|
||||
// Si champ respectant le modèle a été trouvée
|
||||
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
|
||||
{
|
||||
// Recherche rapide car restreint par un like sur champ indexé
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
||||
$sql.= " WHERE ref like '${fayymm}%'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$max = $row[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
$yymm = strftime("%y%m",time());
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
return $this->prefix."$yymm-$num";
|
||||
}
|
||||
|
||||
/** \brief Renvoie la référence de facture suivante non utilisée
|
||||
* \param objsoc Objet société
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function getNumRef($objsoc=0)
|
||||
{
|
||||
return $this->getNextValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -170,6 +170,7 @@ insert into llx_const (name, value, type, visible) values ('COMMANDE_SUPPLIER_AD
|
||||
insert into llx_const (name, value, type, visible) values ('COMMANDE_SUPPLIER_ADDON_PDF', 'muscadet','chaine',0);
|
||||
insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON', 'enlevement','chaine',0);
|
||||
insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON_PDF','rouget','chaine',0);
|
||||
insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON', 'pacific','chaine',0);
|
||||
insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON_PDF','soleil','chaine',0);
|
||||
insert into llx_const (name, value, type, visible) values ('FACTURE_ADDON', 'terre','chaine',0);
|
||||
insert into llx_const (name, value, type, visible) values ('FACTURE_ADDON_PDF', 'crabe','chaine',0);
|
||||
|
||||
@ -207,6 +207,7 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (29
|
||||
update llx_const set value='neptune' where value='pluton' and name = 'FACTURE_ADDON';
|
||||
update llx_const set value='azur' where value='orange' and name = 'PROPALE_ADDON';
|
||||
update llx_const set value='mod_commande_diamant' where value='mod_commande_jade' and name ='COMMANDE_ADDON';
|
||||
insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON', 'pacific','chaine',0);
|
||||
|
||||
alter table llx_propal_model_pdf rename to llx_document_model;
|
||||
alter table llx_document_model DROP PRIMARY KEY;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user