diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 9fdf688dfa5..cc1c47c12e2 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2006-2008 Laurent Destailleur + * Copyright (C) 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 @@ -84,7 +85,56 @@ class Expedition extends CommonObject $this->statuts[0] = 'StatusSendingDraft'; $this->statuts[1] = 'StatusSendingValidated'; } + + /** + * Return next contract ref + * @param soc objet society + * @return string free reference for contract + */ + function getNextNumRef($soc) + { + global $db, $langs, $conf; + $langs->load("sendings"); + $dir = DOL_DOCUMENT_ROOT . "/includes/modules/expedition"; + + if (! empty($conf->global->EXPEDITION_ADDON_NUMBER)) + { + $file = $conf->global->EXPEDITION_ADDON_NUMBER.".php"; + + // Chargement de la classe de numerotation + $classname = $conf->global->EXPEDITION_ADDON_NUMBER; + + $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,"Expedition::getNextNumRef ".$obj->error); + return ""; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); + return ""; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); + return ""; + } + } + /** * \brief Cree expedition en base * \param user Objet du user qui cree @@ -364,8 +414,22 @@ class Expedition extends CommonObject $error = 0; // Define new ref - $num = "EXP".$this->id; + $soc = new Societe($this->db); + $soc->fetch($this->socid); + // Class of company linked to order + $result=$soc->set_as_client(); + + // Define new ref + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + { + $num = $this->getNextNumRef($soc); + } + else + { + $num = "EXP".$this->id; + } + $now=dol_now(); // Validate diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 44aabdc8363..cdb219773f3 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 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 @@ -701,7 +702,16 @@ else */ if ($_GET["action"] == 'valid') { - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),$langs->trans("ConfirmValidateSending",$expedition->ref),'confirm_valid','',0,1); + $objectref = substr($expedition->ref, 1, 4); + if ($objectref == 'PROV') + { + $numref = $expedition->getNextNumRef($soc); + } + else + { + $numref = $expedition->ref; + } + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),$langs->trans("ConfirmValidateSending",$numref),'confirm_valid','',0,1); if ($ret == 'html') print '
'; } /* diff --git a/htdocs/langs/ca_ES/sendings.lang b/htdocs/langs/ca_ES/sendings.lang index 60504321a65..e41b012c06f 100644 --- a/htdocs/langs/ca_ES/sendings.lang +++ b/htdocs/langs/ca_ES/sendings.lang @@ -34,7 +34,7 @@ StatusSendingValidated=Validat (productes a enviar o enviats) StatusSendingCanceledShort=Anul.lat StatusSendingDraftShort=Esborrany StatusSendingValidatedShort=Validat -SendingSheet=Fitxa d'enviament +SendingSheet=Nota de lliurament Carriers=Transportistes Carrier=Transportista CarriersArea=Àrea transportistes @@ -57,3 +57,4 @@ SendingMethodCOLSUI=Colissimo # ModelDocument DocumentModelSirocco=Model simple nota de lliurament DocumentModelTyphon=Model complet de nota de lliurament (logo...) +Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER no definida \ No newline at end of file diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 2a7107fb5aa..6d580df49c9 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -40,7 +40,7 @@ Carrier=Carrier CarriersArea=Carriers area NewCarrier=New carrier ConfirmDeleteSending=Are you sure you want to delete this shipment ? -ConfirmValidateSending=Are you sure you want to validate this shipment ? +ConfirmValidateSending=Are you sure you want to validate this shipment with reference %s ? ConfirmCancelSending=Are you sure you want to cancel this shipment ? GenericTransport=Generic transport Enlevement=Gotten by customer @@ -59,3 +59,5 @@ SendingMethodCOLSUI=Colissimo # ModelDocument DocumentModelSirocco=Simple document model for delivery receipts DocumentModelTyphon=More complete document model for delivery receipts (logo...) + +Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER not defined diff --git a/htdocs/langs/es_AR/sendings.lang b/htdocs/langs/es_AR/sendings.lang index a670272dc13..5db8a77d8a6 100755 --- a/htdocs/langs/es_AR/sendings.lang +++ b/htdocs/langs/es_AR/sendings.lang @@ -35,13 +35,13 @@ StatusSendingValidated=Validado (productos a enviar o enviados) StatusSendingCanceledShort=Anulado StatusSendingDraftShort=Borrador StatusSendingValidatedShort=Validado -SendingSheet=Ficha de envío +SendingSheet=Nota de entrega Carriers=Transportistas Carrier=Transportista CarriersArea=Área transportistas NewCarrier=Nuevo transportista ConfirmDeleteSending=¿Está seguro de querer eliminar esta expedición? -ConfirmValidateSending=¿Está seguro de querer validar esta expedición? +ConfirmValidateSending=¿Está seguro de querer validar esta expedición con la referencia %s? ConfirmCancelSending=¿Está seguro de querer anular esta expedición? GenericTransport=Transporte genérico Enlevement=Pick-up por el cliente @@ -57,4 +57,5 @@ SendingMethodTRANS=Transportista SendingMethodCOLSUI=Colissimo # ModelDocument DocumentModelSirocco=Modelo simple de nota de entrega / recepción -DocumentModelTyphon=Modelo completo de nota de entrega / recepción (logo...) \ No newline at end of file +DocumentModelTyphon=Modelo completo de nota de entrega / recepción (logo...) +Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constante EXPEDITION_ADDON_NUMBER no definida \ No newline at end of file diff --git a/htdocs/langs/es_ES/sendings.lang b/htdocs/langs/es_ES/sendings.lang index 568bdf4bee9..5160a6fb70a 100644 --- a/htdocs/langs/es_ES/sendings.lang +++ b/htdocs/langs/es_ES/sendings.lang @@ -34,13 +34,13 @@ StatusSendingValidated=Validado (productos a enviar o enviados) StatusSendingCanceledShort=Anulado StatusSendingDraftShort=Borrador StatusSendingValidatedShort=Validado -SendingSheet=Ficha de envío +SendingSheet=Nota de entrega Carriers=Transportistas Carrier=Transportista CarriersArea=Área transportistas NewCarrier=Nuevo transportista ConfirmDeleteSending=¿Está seguro de querer eliminar esta expedición? -ConfirmValidateSending=¿Está seguro de querer validar esta expedición? +ConfirmValidateSending=¿Está seguro de querer validar esta expedición con la referencia %s? ConfirmCancelSending=¿Está seguro de querer anular esta expedición? GenericTransport=Transporte genérico Enlevement=Pick-up por el cliente @@ -57,3 +57,4 @@ SendingMethodCOLSUI=Colissimo # ModelDocument DocumentModelSirocco=Modelo simple de nota de entrega / recepción DocumentModelTyphon=Modelo completo de nota de entrega / recepción (logo...) +Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constante EXPEDITION_ADDON_NUMBER no definida \ No newline at end of file diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 6dba4cc0298..9a58f12a9ff 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -40,7 +40,7 @@ Carrier=Transporteur CarriersArea=Espace transporteurs NewCarrier=Nouveau transporteur ConfirmDeleteSending=Êtes-vous sûr de vouloir supprimer cette expédition ? -ConfirmValidateSending=Êtes-vous sûr de vouloir valider cette expédition ? +ConfirmValidateSending=Êtes-vous sûr de vouloir valider cette expédition sous la référence %s? ConfirmCancelSending=Êtes-vous sûr de vouloir annuler cette expédition ? GenericTransport=Transporteur générique Enlevement=Enlèvement sur place par le client @@ -59,3 +59,5 @@ SendingMethodCOLSUI=Colissimo Suivi # ModelDocument DocumentModelSirocco=Modèle de bon de réception/livraison simple DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo...) + +Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constante EXPEDITION_ADDON_NUMBER non définie \ No newline at end of file