diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php index 923eff12936..71f6a50e420 100644 --- a/htdocs/admin/project.php +++ b/htdocs/admin/project.php @@ -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(); diff --git a/htdocs/includes/modules/project/mod_project_simple.php b/htdocs/includes/modules/project/mod_project_simple.php new file mode 100644 index 00000000000..53ef702d1ab --- /dev/null +++ b/htdocs/includes/modules/project/mod_project_simple.php @@ -0,0 +1,114 @@ + + * + * 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); + } +} + +?> \ No newline at end of file diff --git a/htdocs/includes/modules/project/mod_project_universal.php b/htdocs/includes/modules/project/mod_project_universal.php index 6e5e6f7b4b4..4efa78ed0d3 100644 --- a/htdocs/includes/modules/project/mod_project_universal.php +++ b/htdocs/includes/modules/project/mod_project_universal.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010 Regis Houssin * * 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='') { diff --git a/htdocs/includes/modules/propale/mod_propale_marbre.php b/htdocs/includes/modules/propale/mod_propale_marbre.php index c8b68a8be12..bab038892ce 100644 --- a/htdocs/includes/modules/propale/mod_propale_marbre.php +++ b/htdocs/includes/modules/propale/mod_propale_marbre.php @@ -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); + } + } ?> diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 04735a576e4..fd4d4e14502 100755 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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 diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index bd8107e1af2..a8389051cca 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -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 diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 500549d43ba..346611e1931 100755 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -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 diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index d5a93583349..aa179a089e0 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -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 diff --git a/htdocs/projet/project.class.php b/htdocs/projet/project.class.php index c6daa94cfed..fd7f5daaa6d 100644 --- a/htdocs/projet/project.class.php +++ b/htdocs/projet/project.class.php @@ -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++; } } - + } ?>