Task #10577: Works with shipments

This commit is contained in:
Juanjo Menent 2011-02-20 00:20:45 +00:00
parent 560ada001b
commit 08114f30d9
7 changed files with 91 additions and 10 deletions

View File

@ -3,6 +3,7 @@
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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

View File

@ -3,6 +3,7 @@
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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 '<br>';
}
/*

View File

@ -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

View File

@ -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 <b>%s</b> ?
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

View File

@ -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 <b>%s</b>?
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...)
DocumentModelTyphon=Modelo completo de nota de entrega / recepción (logo...)
Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constante EXPEDITION_ADDON_NUMBER no definida

View File

@ -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 <b>%s</b>?
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

View File

@ -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 <b>%s</b>?
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