diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4f3782870ac..dfe7bb47e82 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2011 Juanjo Menent * * 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 @@ -88,6 +88,55 @@ class Contrat extends CommonObject $this->user_cloture = new User($DB); } + /** + * Return next contract ref + * @param soc objet society + * @return string free reference for contract + */ + function getNextNumRef($soc) + { + global $db, $langs, $conf; + $langs->load("contract"); + + $dir = DOL_DOCUMENT_ROOT . "/includes/modules/contract"; + + if (! empty($conf->global->CONTRACT_ADDON)) + { + $file = $conf->global->CONTRACT_ADDON.".php"; + + // Chargement de la classe de numerotation + $classname = $conf->global->CONTRACT_ADDON; + + $result=include_once($dir.'/'.$file); + if ($result) + { + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); + + if ( $numref != "") + { + return $numref; + } + else + { + dol_print_error($db,"Contract::getNextNumRef ".$obj->error); + return ""; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined"); + return ""; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined"); + return ""; + } + } + /** * \brief Activate a contract line * \param user Objet User qui active le contrat diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index ae5a29e6580..94f06ed0b5a 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2011 Juanjo Menent * * 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 @@ -30,6 +30,7 @@ require ("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/includes/modules/contract/modules_contract.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); @@ -479,6 +480,12 @@ if ($_GET["action"] == 'create') $soc = new Societe($db); $soc->fetch($socid); + $contract = new Contrat($db); + $contract->date_contrat = time(); + if ($contratid) $result=$contract->fetch($contratid); + + $numct = $contract->getNextNumRef($soc); + print '
'; print ''; @@ -490,7 +497,7 @@ if ($_GET["action"] == 'create') // Ref print ''.$langs->trans("Ref").''; - print ''; + print ''; // Customer print ''.$langs->trans("Customer").''.$soc->getNomUrl(1).''; diff --git a/htdocs/langs/ca_ES/contracts.lang b/htdocs/langs/ca_ES/contracts.lang index 5742daa60d7..aeba02d7cab 100644 --- a/htdocs/langs/ca_ES/contracts.lang +++ b/htdocs/langs/ca_ES/contracts.lang @@ -90,3 +90,4 @@ TypeContact_contrat_internal_SALESREPFOLL= Comercial seguiment del contracte TypeContact_contrat_external_BILLING= Contacte client de facturació del contracte TypeContact_contrat_external_CUSTOMER= Contacte client seguiment del contracte TypeContact_contrat_external_SALESREPSIGN= Contacte client signant del contracte +Error_CONTRACT_ADDON_NotDefined=Constant CONTRACT_ADDON no definida \ No newline at end of file diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index ab98cf80133..d3f64feef96 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -91,3 +91,4 @@ TypeContact_contrat_internal_SALESREPFOLL=Sales representative following-up cont TypeContact_contrat_external_BILLING=Billing customer contact TypeContact_contrat_external_CUSTOMER=Follow-up customer contact TypeContact_contrat_external_SALESREPSIGN=Signing contract customer contact +Error_CONTRACT_ADDON_NotDefined=Constant CONTRACT_ADDON not defined \ No newline at end of file diff --git a/htdocs/langs/es_AR/contracts.lang b/htdocs/langs/es_AR/contracts.lang index c3d00bccd4d..73a2e0b8779 100755 --- a/htdocs/langs/es_AR/contracts.lang +++ b/htdocs/langs/es_AR/contracts.lang @@ -90,3 +90,4 @@ TypeContact_contrat_internal_SALESREPFOLL= Comercial seguimiento del contrato TypeContact_contrat_external_BILLING= Contacto cliente de facturación del contrato TypeContact_contrat_external_CUSTOMER= Contacto cliente seguimiento del contrato TypeContact_contrat_external_SALESREPSIGN= Contacto cliente firmante del contrato +Error_CONTRACT_ADDON_NotDefined=Constante CONTRACT_ADDON no definida \ No newline at end of file diff --git a/htdocs/langs/es_ES/contracts.lang b/htdocs/langs/es_ES/contracts.lang index 339e7517674..64ea048c469 100644 --- a/htdocs/langs/es_ES/contracts.lang +++ b/htdocs/langs/es_ES/contracts.lang @@ -90,3 +90,4 @@ TypeContact_contrat_internal_SALESREPFOLL= Comercial seguimiento del contrato TypeContact_contrat_external_BILLING= Contacto cliente de facturación del contrato TypeContact_contrat_external_CUSTOMER= Contacto cliente seguimiento del contrato TypeContact_contrat_external_SALESREPSIGN= Contacto cliente firmante del contrato +Error_CONTRACT_ADDON_NotDefined=Constante CONTRACT_ADDON no definida diff --git a/htdocs/langs/fr_FR/contracts.lang b/htdocs/langs/fr_FR/contracts.lang index 8b314539b17..55a0719a46d 100644 --- a/htdocs/langs/fr_FR/contracts.lang +++ b/htdocs/langs/fr_FR/contracts.lang @@ -91,3 +91,4 @@ TypeContact_contrat_internal_SALESREPFOLL=Commercial suivi du contrat TypeContact_contrat_external_BILLING=Contact client facturation contrat TypeContact_contrat_external_CUSTOMER=Contact client suivi contrat TypeContact_contrat_external_SALESREPSIGN=Contact client signataire contrat +Error_CONTRACT_ADDON_NotDefined=Constante CONTRACT_ADDON non définie \ No newline at end of file