Add a more simple project numbering module to have always for each module:
1 simple module with no need to understand masks. 1 generic module with a masks to define.
This commit is contained in:
parent
0943a28445
commit
1d0a197f85
@ -30,6 +30,7 @@ require_once(DOL_DOCUMENT_ROOT.'/projet/tasks/task.class.php');
|
|||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
$langs->load("projects");
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|||||||
114
htdocs/includes/modules/project/mod_project_simple.php
Normal file
114
htdocs/includes/modules/project/mod_project_simple.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
*
|
||||||
|
* 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/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/includes/modules/project/mod_project_simple.php
|
||||||
|
* \ingroup project
|
||||||
|
* \brief File with class to manage the numbering module Simple for project references
|
||||||
|
* \version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/project/modules_project.php");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class mod_project_simple
|
||||||
|
* \brief Class to manage the numbering module Simple for project references
|
||||||
|
*/
|
||||||
|
class mod_project_simple extends ModeleNumRefProjects
|
||||||
|
{
|
||||||
|
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
var $prefix='PJ';
|
||||||
|
var $error='';
|
||||||
|
var $nom = "Simple";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Return description of numbering module
|
||||||
|
* \return string Text with description
|
||||||
|
*/
|
||||||
|
function info()
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
return $langs->trans("SimpleNumRefModelDesc");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Return an example of numbering module values
|
||||||
|
* \return string Example
|
||||||
|
*/
|
||||||
|
function getExample()
|
||||||
|
{
|
||||||
|
return $this->prefix."0501-0001";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return next value
|
||||||
|
* \param objsoc Object third party
|
||||||
|
* \param project Object project
|
||||||
|
* \return string Value if OK, 0 if KO
|
||||||
|
*/
|
||||||
|
function getNextValue($objsoc=0,$project='')
|
||||||
|
{
|
||||||
|
global $db,$conf;
|
||||||
|
|
||||||
|
// D'abord on recupere la valeur max (reponse immediate car champ indexe)
|
||||||
|
$posindice=8;
|
||||||
|
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
|
||||||
|
$sql.= " WHERE ref like '".$this->prefix."%'";
|
||||||
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
if ($obj) $max = $obj->max;
|
||||||
|
else $max=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog("mod_project_simple::getNextValue sql=".$sql);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$date=$project->date_c;
|
||||||
|
//$yymm = strftime("%y%m",time());
|
||||||
|
$yymm = strftime("%y%m",$date);
|
||||||
|
$num = sprintf("%04s",$max+1);
|
||||||
|
|
||||||
|
dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
|
return $this->prefix.$yymm."-".$num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Return next reference not yet used as a reference
|
||||||
|
* \param objsoc Object third party
|
||||||
|
* \param project Object project
|
||||||
|
* \return string Next not used reference
|
||||||
|
*/
|
||||||
|
function project_get_num($objsoc=0,$project='')
|
||||||
|
{
|
||||||
|
return $this->getNextValue($objsoc,$project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 20010 Regis Houssin <regis@dolibarr.fr>
|
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -101,7 +101,7 @@ class mod_project_universal extends ModeleNumRefProjects
|
|||||||
/**
|
/**
|
||||||
* \brief Return next value
|
* \brief Return next value
|
||||||
* \param objsoc Object third party
|
* \param objsoc Object third party
|
||||||
* \param commande Object project
|
* \param project Object project
|
||||||
* \return string Value if OK, 0 if KO
|
* \return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
function getNextValue($objsoc=0,$project='')
|
function getNextValue($objsoc=0,$project='')
|
||||||
@ -119,16 +119,16 @@ class mod_project_universal extends ModeleNumRefProjects
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$numFinal=get_next_value($db,$mask,'projet','ref','',$objsoc->code_client,$project->datec);
|
$numFinal=get_next_value($db,$mask,'projet','ref','',$objsoc->code_client,$project->date_c);
|
||||||
|
|
||||||
return $numFinal;
|
return $numFinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoie la reference de commande suivante non utilisee
|
/** \brief Return next reference not yet used as a reference
|
||||||
* \param objsoc Object third party
|
* \param objsoc Object third party
|
||||||
* \param commande Object project
|
* \param project Object project
|
||||||
* \return string Texte descripif
|
* \return string Next not used reference
|
||||||
*/
|
*/
|
||||||
function project_get_num($objsoc=0,$project='')
|
function project_get_num($objsoc=0,$project='')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -19,19 +19,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/includes/modules/propale/mod_propale_marbre.php
|
* \file htdocs/includes/modules/propale/mod_propale_marbre.php
|
||||||
\ingroup propale
|
* \ingroup propale
|
||||||
\brief Fichier contenant la classe du modele de numerotation de reference de propale Marbre
|
* \brief Fichier contenant la classe du modele de numerotation de reference de propale Marbre
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
||||||
|
|
||||||
|
|
||||||
/** \class mod_propale_marbre
|
/** \class mod_propale_marbre
|
||||||
\brief Classe du modele de numerotation de reference de propale Marbre
|
* \brief Classe du modele de numerotation de reference de propale Marbre
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class mod_propale_marbre extends ModeleNumRefPropales
|
class mod_propale_marbre extends ModeleNumRefPropales
|
||||||
{
|
{
|
||||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
@ -40,8 +39,8 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
|||||||
var $nom = "Marbre";
|
var $nom = "Marbre";
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numerotation
|
/** \brief Return description of numbering module
|
||||||
* \return string Texte descripif
|
* \return string Text with description
|
||||||
*/
|
*/
|
||||||
function info()
|
function info()
|
||||||
{
|
{
|
||||||
@ -50,12 +49,12 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numerotation
|
/** \brief Return an example of numbering module values
|
||||||
* \return string Example
|
* \return string Example
|
||||||
*/
|
*/
|
||||||
function getExample()
|
function getExample()
|
||||||
{
|
{
|
||||||
return "PR0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -71,3 +71,5 @@ TypeContact_project_task_internal_CONTRIBUTOR=Contributor
|
|||||||
TypeContact_project_task_external_CONTRIBUTOR=Contributor
|
TypeContact_project_task_external_CONTRIBUTOR=Contributor
|
||||||
# Documents models
|
# Documents models
|
||||||
DocumentModelBaleine=A complete project's report model (logo...)
|
DocumentModelBaleine=A complete project's report model (logo...)
|
||||||
|
# NumRef Modules
|
||||||
|
SimpleNumRefModelDesc=Return the reference number with format PJyymm-nnnn where yy is year, mm is month and nnnn is a sequence without hole and with no reset
|
||||||
|
|||||||
@ -85,10 +85,8 @@ ProposalLine=Proposal line
|
|||||||
TypeContact_propal_internal_SALESREPFOLL=Representative following-up proposal
|
TypeContact_propal_internal_SALESREPFOLL=Representative following-up proposal
|
||||||
TypeContact_propal_external_BILLING=Customer invoice contact
|
TypeContact_propal_external_BILLING=Customer invoice contact
|
||||||
TypeContact_propal_external_CUSTOMER=Customer contact following-up proposal
|
TypeContact_propal_external_CUSTOMER=Customer contact following-up proposal
|
||||||
|
|
||||||
# Document models
|
# Document models
|
||||||
DocModelAzurDescription=A complete proposal model (logo...)
|
DocModelAzurDescription=A complete proposal model (logo...)
|
||||||
DocModelJauneDescription=Jaune proposal model
|
DocModelJauneDescription=Jaune proposal model
|
||||||
|
|
||||||
# NumRef Modules
|
# NumRef Modules
|
||||||
MarbreNumRefModelDesc=Return numero with format %syymm-nnnn for proposals where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
|
MarbreNumRefModelDesc=Return numero with format %syymm-nnnn for proposals where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
|
||||||
|
|||||||
@ -71,3 +71,5 @@ TypeContact_project_task_internal_CONTRIBUTOR=Intervenant
|
|||||||
TypeContact_project_task_external_CONTRIBUTOR=Intervenant
|
TypeContact_project_task_external_CONTRIBUTOR=Intervenant
|
||||||
# Documents models
|
# Documents models
|
||||||
DocumentModelBaleine=Modèle de rapport de projet complet (logo...)
|
DocumentModelBaleine=Modèle de rapport de projet complet (logo...)
|
||||||
|
# NumRef Modules
|
||||||
|
SimpleNumRefModelDesc=Renvoie le numero sous la forme PJyymm-nnnn où yy est l'annee, mm le mois et nnnn un compteur sequentiel sans rupture et sans remise à 0
|
||||||
|
|||||||
@ -85,10 +85,8 @@ ProposalLine=Ligne de proposition
|
|||||||
TypeContact_propal_internal_SALESREPFOLL=Commercial suivi propale
|
TypeContact_propal_internal_SALESREPFOLL=Commercial suivi propale
|
||||||
TypeContact_propal_external_BILLING=Contact client facturation propale
|
TypeContact_propal_external_BILLING=Contact client facturation propale
|
||||||
TypeContact_propal_external_CUSTOMER=Contact client suivi propale
|
TypeContact_propal_external_CUSTOMER=Contact client suivi propale
|
||||||
|
|
||||||
# Documents models
|
# Documents models
|
||||||
DocModelAzurDescription=Modèle de propositions commerciales complet (logo...)
|
DocModelAzurDescription=Modèle de propositions commerciales complet (logo...)
|
||||||
DocModelJauneDescription=Modele de proposition Jaune
|
DocModelJauneDescription=Modele de proposition Jaune
|
||||||
|
|
||||||
# NumRef Modules
|
# NumRef Modules
|
||||||
MarbreNumRefModelDesc=Renvoie le numero sous la forme PRyymm-nnnn où yy est l'annee, mm le mois et nnnn un compteur sequentiel sans rupture et sans remise à 0
|
MarbreNumRefModelDesc=Renvoie le numero sous la forme PRyymm-nnnn où yy est l'annee, mm le mois et nnnn un compteur sequentiel sans rupture et sans remise à 0
|
||||||
|
|||||||
@ -530,6 +530,8 @@ class Project extends CommonObject
|
|||||||
{
|
{
|
||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
|
$now=mktime();
|
||||||
|
|
||||||
// Charge tableau des id de societe socids
|
// Charge tableau des id de societe socids
|
||||||
$socids = array();
|
$socids = array();
|
||||||
|
|
||||||
@ -580,7 +582,9 @@ class Project extends CommonObject
|
|||||||
$this->specimen=1;
|
$this->specimen=1;
|
||||||
$socid = rand(1, $num_socs);
|
$socid = rand(1, $num_socs);
|
||||||
$this->socid = $socids[$socid];
|
$this->socid = $socids[$socid];
|
||||||
$this->dateo = time();
|
$this->date_c = $now;
|
||||||
|
$this->date_m = $now;
|
||||||
|
$this->date_start = $now;
|
||||||
$this->note_public='SPECIMEN';
|
$this->note_public='SPECIMEN';
|
||||||
$nbp = rand(1, 9);
|
$nbp = rand(1, 9);
|
||||||
$xnbp = 0;
|
$xnbp = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user