2006-02-17 18:36:33 +01:00
< ? php
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 - 2006 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 $
*
*/
/**
2006-05-06 16:51:58 +02:00
\file htdocs / fourn / commande / modules / pdf / mod_commande_fournisseur_rose . php
2006-02-17 18:36:33 +01:00
\ingroup fournisseur
2007-05-15 17:53:46 +02:00
\brief Fichier contenant la classe du mod<EFBFBD> le de num<EFBFBD> rotation de r<EFBFBD> f<EFBFBD> rence de commande fournisseur Rose
2006-02-17 18:36:33 +01:00
\version $Revision $
*/
2007-05-15 17:53:46 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /fourn/commande/modules/modules_commandefournisseur.php " );
2006-02-17 18:36:33 +01:00
/**
2006-05-06 16:51:58 +02:00
\class mod_commande_fournisseur_rose
\brief Classe du mod<EFBFBD> le de num<EFBFBD> rotation de r<EFBFBD> f<EFBFBD> rence de commande fournisseur Rose
2006-02-17 18:36:33 +01:00
*/
2007-05-15 17:53:46 +02:00
class mod_commande_fournisseur_rose extends ModeleNumRefSuppliersOrders
2006-02-17 18:36:33 +01:00
{
/** \brief Constructeur
*/
2006-05-06 16:51:58 +02:00
function mod_commande_fournisseur_rose ()
2006-02-17 18:36:33 +01:00
{
2006-05-06 16:51:58 +02:00
$this -> nom = " Rose " ;
2006-02-17 18:36:33 +01:00
}
/** \brief Renvoi la description du modele de num<EFBFBD> rotation
* \return string Texte descripif
*/
function info ()
{
2006-02-19 12:05:18 +01:00
$texte = " Renvoie le num<75> ro sous la forme num<75> rique CFYYNNNN, o<> YY repr<70> sente l'ann<6E> e et NNNN Le num<75> ro d'incr<63> ment. Ce dernier n'est PAS remis <20> z<> ro en d<> but d'ann<6E> e.<br> \n " ;
2006-05-06 16:51:58 +02:00
$texte .= " Si la constante COMMANDE_FOURNISSEUR_ROSE_DELTA est d<> finie, un offset est appliqu<71> sur le compteur " ;
2006-02-17 18:36:33 +01:00
2006-05-06 16:51:58 +02:00
if ( defined ( " COMMANDE_FOURNISSEUR_ROSE_DELTA " ))
2006-02-17 18:36:33 +01:00
{
2006-05-06 16:51:58 +02:00
$texte .= " (D<> finie et vaut: " . COMMANDE_FOURNISSEUR_ROSE_DELTA . " ) " ;
2006-02-17 18:36:33 +01:00
}
else
{
$texte .= " (N'est pas d<> finie) " ;
}
return $texte ;
}
/** \brief Renvoi un exemple de num<EFBFBD> rotation
* \return string Example
*/
function getExample ()
{
$y = strftime ( " %y " , time ());
2006-05-06 16:51:58 +02:00
if ( defined ( " COMMANDE_FOURNISSEUR_ROSE_DELTA " ))
2006-02-17 18:36:33 +01:00
{
2006-05-06 16:51:58 +02:00
$num = sprintf ( " %02d " , COMMANDE_FOURNISSEUR_ROSE_DELTA );
2006-02-19 12:05:18 +01:00
return " CF " . $y . substr ( " 000 " . $num , strlen ( " 000 " . $num ) - 4 , 4 );
2006-02-17 18:36:33 +01:00
}
else
{
2006-02-19 12:05:18 +01:00
return " CF " . $y . " 0001 " ;
2006-02-17 18:36:33 +01:00
}
}
2006-05-06 16:51:58 +02:00
/**
* \brief Renvoie le prochaine num<EFBFBD> ro de r<EFBFBD> f<EFBFBD> rence de commande non utilis<EFBFBD>
* \param objsoc Objet soci<EFBFBD> t<EFBFBD>
* \return string Num<EFBFBD> ro de r<EFBFBD> f<EFBFBD> rence de commande non utilis<EFBFBD>
*/
function getNextValue ( $objsoc = 0 )
{
global $db ;
2006-02-17 18:36:33 +01:00
2006-05-06 16:51:58 +02:00
$sql = " SELECT count(*) FROM " . MAIN_DB_PREFIX . " commande_fournisseur WHERE fk_statut <> 0 " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$row = $db -> fetch_row ( $resql );
$num = $row [ 0 ];
}
if ( ! defined ( " COMMANDE_FOURNISSEUR_ROSE_DELTA " ))
{
define ( " COMMANDE_FOURNISSEUR_ROSE_DELTA " , 0 );
}
$num = $num + COMMANDE_FOURNISSEUR_ROSE_DELTA ;
$y = strftime ( " %y " , time ());
return 'CF' . $y . sprintf ( " %04s " , $num );
}
/** \brief Renvoie la r<EFBFBD> f<EFBFBD> rence de commande suivante non utilis<EFBFBD> e
* \param objsoc Objet soci<EFBFBD> t<EFBFBD>
* \return string Texte descripif
*/
function commande_get_num ( $objsoc = 0 )
{
return $this -> getNextValue ( $objsoc );
}
2006-02-17 18:36:33 +01:00
}
?>