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("other");
|
||||
$langs->load("projects");
|
||||
|
||||
if (!$user->admin)
|
||||
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
|
||||
/* 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
|
||||
* 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
|
||||
* \param objsoc Object third party
|
||||
* \param commande Object project
|
||||
* \param project Object project
|
||||
* \return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc=0,$project='')
|
||||
@ -119,16 +119,16 @@ class mod_project_universal extends ModeleNumRefProjects
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/** \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 commande Object project
|
||||
* \return string Texte descripif
|
||||
* \param project Object project
|
||||
* \return string Next not used reference
|
||||
*/
|
||||
function project_get_num($objsoc=0,$project='')
|
||||
{
|
||||
|
||||
@ -19,125 +19,124 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/modules/propale/mod_propale_marbre.php
|
||||
\ingroup propale
|
||||
\brief Fichier contenant la classe du modele de numerotation de reference de propale Marbre
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/includes/modules/propale/mod_propale_marbre.php
|
||||
* \ingroup propale
|
||||
* \brief Fichier contenant la classe du modele de numerotation de reference de propale Marbre
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
|
||||
|
||||
|
||||
/** \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
|
||||
{
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
var $prefix='PR';
|
||||
var $error='';
|
||||
var $error='';
|
||||
var $nom = "Marbre";
|
||||
|
||||
|
||||
/** \brief Renvoi la description du modele de numerotation
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function info()
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("MarbreNumRefModelDesc");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi un exemple de numerotation
|
||||
* \return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
return "PR0501-0001";
|
||||
}
|
||||
/** \brief Return description of numbering module
|
||||
* \return string Text with description
|
||||
*/
|
||||
function info()
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("MarbreNumRefModelDesc");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Test si les numeros deje en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
* \return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$pryymm='';
|
||||
|
||||
$sql = "SELECT MAX(ref)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) $pryymm = substr($row[0],0,6);
|
||||
}
|
||||
if (! $pryymm || preg_match('/PR[0-9][0-9][0-9][0-9]/i',$pryymm))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error='Une propal commencant par $pryymm existe en base et est incompatible avec cette numerotation. Supprimer la ou renommer la pour activer ce module.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** \brief Return an example of numbering module values
|
||||
* \return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
return $this->prefix."0501-0001";
|
||||
}
|
||||
|
||||
|
||||
/** \brief Test si les numeros deje en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
* \return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$pryymm='';
|
||||
|
||||
$sql = "SELECT MAX(ref)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= " WHERE entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) $pryymm = substr($row[0],0,6);
|
||||
}
|
||||
if (! $pryymm || preg_match('/PR[0-9][0-9][0-9][0-9]/i',$pryymm))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error='Une propal commencant par $pryymm existe en base et est incompatible avec cette numerotation. Supprimer la ou renommer la pour activer ce module.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Return next value
|
||||
* \param objsoc Object third party
|
||||
* \param propal Object commercial proposal
|
||||
* \return string Valeur
|
||||
*/
|
||||
* \param objsoc Object third party
|
||||
* \param propal Object commercial proposal
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue($objsoc,$propal)
|
||||
{
|
||||
global $db,$conf;
|
||||
{
|
||||
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."propal";
|
||||
$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_propale_marbre::getNextValue sql=".$sql);
|
||||
return -1;
|
||||
}
|
||||
// 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."propal";
|
||||
$sql.= " WHERE ref like '".$this->prefix."%'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
$date=$propal->date;
|
||||
//$yymm = strftime("%y%m",time());
|
||||
$yymm = strftime("%y%m",$date);
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
dol_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
}
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $max = $obj->max;
|
||||
else $max=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("mod_propale_marbre::getNextValue sql=".$sql);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$date=$propal->date;
|
||||
//$yymm = strftime("%y%m",time());
|
||||
$yymm = strftime("%y%m",$date);
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
dol_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
}
|
||||
|
||||
/** \brief Return next free value
|
||||
* \param objsoc Object third party
|
||||
* \param objforref Object for number to search
|
||||
* \return string Next free value
|
||||
*/
|
||||
function getNumRef($objsoc,$objforref)
|
||||
{
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
* \param objsoc Object third party
|
||||
* \param objforref Object for number to search
|
||||
* \return string Next free value
|
||||
*/
|
||||
function getNumRef($objsoc,$objforref)
|
||||
{
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -71,3 +71,5 @@ TypeContact_project_task_internal_CONTRIBUTOR=Contributor
|
||||
TypeContact_project_task_external_CONTRIBUTOR=Contributor
|
||||
# Documents models
|
||||
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_external_BILLING=Customer invoice contact
|
||||
TypeContact_propal_external_CUSTOMER=Customer contact following-up proposal
|
||||
|
||||
# Document models
|
||||
DocModelAzurDescription=A complete proposal model (logo...)
|
||||
DocModelJauneDescription=Jaune proposal model
|
||||
|
||||
# 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
|
||||
|
||||
@ -71,3 +71,5 @@ TypeContact_project_task_internal_CONTRIBUTOR=Intervenant
|
||||
TypeContact_project_task_external_CONTRIBUTOR=Intervenant
|
||||
# Documents models
|
||||
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_external_BILLING=Contact client facturation propale
|
||||
TypeContact_propal_external_CUSTOMER=Contact client suivi propale
|
||||
|
||||
# Documents models
|
||||
DocModelAzurDescription=Modèle de propositions commerciales complet (logo...)
|
||||
DocModelJauneDescription=Modele de proposition Jaune
|
||||
|
||||
# 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
|
||||
|
||||
@ -132,7 +132,7 @@ class Project extends CommonObject
|
||||
// Clean parameters
|
||||
$this->title = trim($this->title);
|
||||
$this->description = trim($this->description);
|
||||
|
||||
|
||||
if (strlen(trim($this->ref)) > 0)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet SET";
|
||||
@ -235,7 +235,7 @@ class Project extends CommonObject
|
||||
function liste_array($socid='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$projects = array();
|
||||
|
||||
$sql = "SELECT rowid, title";
|
||||
@ -522,7 +522,7 @@ class Project extends CommonObject
|
||||
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialise object with default value to be used as example
|
||||
*/
|
||||
@ -530,15 +530,17 @@ class Project extends CommonObject
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
|
||||
$now=mktime();
|
||||
|
||||
// Charge tableau des id de societe socids
|
||||
$socids = array();
|
||||
|
||||
|
||||
$sql = "SELECT rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql.= " WHERE client IN (1, 3)";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " LIMIT 10";
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -555,12 +557,12 @@ class Project extends CommonObject
|
||||
|
||||
// Charge tableau des produits prodids
|
||||
$prodids = array();
|
||||
|
||||
|
||||
$sql = "SELECT rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
$sql.= " WHERE envente = 1";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -580,7 +582,9 @@ class Project extends CommonObject
|
||||
$this->specimen=1;
|
||||
$socid = rand(1, $num_socs);
|
||||
$this->socid = $socids[$socid];
|
||||
$this->dateo = time();
|
||||
$this->date_c = $now;
|
||||
$this->date_m = $now;
|
||||
$this->date_start = $now;
|
||||
$this->note_public='SPECIMEN';
|
||||
$nbp = rand(1, 9);
|
||||
$xnbp = 0;
|
||||
@ -594,6 +598,6 @@ class Project extends CommonObject
|
||||
$xnbp++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user