Task #10577: Works with shipments

This commit is contained in:
Juanjo Menent 2011-02-19 22:53:25 +00:00
parent 020218b7ef
commit c744f80305
10 changed files with 494 additions and 1 deletions

View File

@ -5,6 +5,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 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
@ -213,10 +214,21 @@ if ($_GET["action"] == 'setmod')
dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["module"],'chaine',0,'',$conf->entity);
}
if ($_POST["action"] == 'updateMask')
{
$maskconst=$_POST['maskconstexpedition'];
$maskvalue=$_POST['maskexpedition'];
if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
}
if ($_GET["action"] == 'setmodel')
{
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$_GET["value"],'chaine',0,'',$conf->entity);
}
/*
* Viewe
* View
*/
$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/";
@ -253,6 +265,101 @@ if ($conf->global->MAIN_SUBMODULE_LIVRAISON)
dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
/*
* Numbering module
*/
//print "<br>";
print_titre($langs->trans("SendingsNumberingModules"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="100">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
print "</tr>\n";
clearstatcache();
//$dir = "../includes/modules/expedition/";
$handle = opendir($dir);
if (is_resource($handle))
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/expedition/".$file.".php");
$module = new $file;
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
print '<td>';
print $module->info();
print '</td>';
// Examples
print '<td nowrap="nowrap">'.$module->getExample()."</td>\n";
print '<td align="center">';
if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
{
print img_picto($langs->trans("Activated"),'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"),'off');
print '</a>';
}
print '</td>';
$expedition=new Expedition($db);
$expedition->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$expedition);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $html->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print '</tr>';
}
}
}
closedir($handle);
}
print '</table><br>';
/*

View File

@ -0,0 +1,131 @@
<?php
/* 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
* 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/expedition/mod_expedition_ribera.php
* \ingroup expedition
* \brief File of class to manage expedition numbering rules Ribera
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/expedition/modules_expedition.php");
/** \class mod_expedition_ribera
* \brief Class to manage expedition numbering rules Ribera
*/
class mod_expedition_ribera extends ModelNumRefExpedition
{
var $version='dolibarr';
var $error = '';
var $nom = 'Ribera';
/**
* Return default description of numbering model
* @return string text description
*/
function info()
{
global $conf,$langs;
$langs->load("bills");
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Sending"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Sending"),$langs->transnoentities("Sending"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Return numbering example
* @return string Example
*/
function getExample()
{
global $conf,$langs,$mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc,'');
$mysoc->code_client=$old_code_client;
if (! $numExample)
{
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
}
/**
* Return next value
* @param objsoc third party object
* @param shipment shipment object
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$shipment)
{
global $db,$conf;
require_once(DOL_DOCUMENT_ROOT ."/lib/functions2.lib.php");
$mask=$conf->global->EXPEDITION_RIBERA_MASK;
if (! $mask)
{
$this->error='NotConfigured';
return 0;
}
$numFinal=get_next_value($db,$mask,'expedition','ref','',$objsoc->code_client,$shipment->date_expedition);
return $numFinal;
}
/**
*Return next free value
* @param objsoc Object third party
* @param objforref Object for number to search
* @return string Next free value
*/
function expedition_get_num($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}
?>

View File

@ -0,0 +1,141 @@
<?php
/* 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
* 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/expedition/mod_expedition_safor.php
* \ingroup expedition
* \brief File of class to manage shipments numbering rules Safor
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/expedition/modules_expedition.php");
/** \class mod_commande_safor
* \brief Class to manage expedition numbering rules Safor
*/
class mod_expedition_safor extends ModelNumRefExpedition
{
var $version='dolibarr';
var $prefix='BE';
var $error='';
var $nom='Safor';
/**
* Return default description of numbering model
* @return string text description
*/
function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
}
/**
* Return numbering example
* @return string Example
*/
function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Test if existing numbers make problems with numbering
* @return boolean false if conflit, true if ok
*/
function canBeActivated()
{
global $conf,$langs;
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
}
if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
return true;
}
/**
* Return next value
* @param objsoc third party object
* @param shipment shipment object
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$shipment)
{
global $db,$conf;
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$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 = intval($obj->max);
else $max=0;
}
else
{
dol_syslog("mod_expedition_safor::getNextValue sql=".$sql);
return -1;
}
$date=time();
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);
dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
/**
*Return next free value
* @param objsoc Object third party
* @param objforref Object for number to search
* @return string Next free value
*/
function expedition_get_num($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}
?>

View File

@ -0,0 +1,101 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.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
* 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/expedition/modules_expedition.php
* \ingroup expedition
* \brief File of class to manage expedition numbering
* \version $Id$
*/
class ModelNumRefExpedition
{
var $error='';
/**
* Return if a module can be used or not
* @return boolean true if module can be used
*/
function isEnabled()
{
return true;
}
/**
* Return default description of numbering model
* @return string text description
*/
function info()
{
global $langs;
$langs->load("sendings");
return $langs->trans("NoDescription");
}
/**
* Return numbering example
* @return string Example
*/
function getExample()
{
global $langs;
$langs->load("sendings");
return $langs->trans("NoExample");
}
/**
* Test if existing numbers make problems with numbering
* @return boolean false if conflit, true if ok
*/
function canBeActivated()
{
return true;
}
/**
* Return next value
* @return string Value
*/
function getNextValue()
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Return numbering version module
* @return string Value
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
return $langs->trans("NotAvailable");
}
}
?>

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 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
@ -106,6 +107,13 @@ class modExpedition extends DolibarrModules
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "EXPEDITION_ADDON_NUMBER";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_expedition_safor";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des expeditions';
$this->const[$r][4] = 0;
$r++;
// Boxes
$this->boxes = array();

View File

@ -1110,6 +1110,7 @@ NotificationEMailFrom=E-Mail emissor (From) dels correus enviats a través de no
##### Sendings #####
SendingsSetup=Configuració del mòdul Expedicions
SendingsReceiptModel=Model de notes de lliurament
SendingsNumberingModules=Mòduls de numeració de notes de lliurament
SendingsAbility=Ús de notes de lliurament per als enviaments a clients
NoNeedForDeliveryReceipts=En la majoria dels casos, les notes de lliurament (llista de productes enviats) també actuen com a notes de recepció i són signades pel client. La gestió de les notes de recepció és per tant redundant i poques vegades s'activarà.
FreeLegalTextOnDeliveryReceipts=Text lliure a les notes de recepció

View File

@ -1106,6 +1106,7 @@ NotificationEMailFrom=Sender EMail (From) for emails sent for notifications
##### Sendings #####
SendingsSetup=Sending module setup
SendingsReceiptModel=Sending receipt model
SendingsNumberingModules=Sendings numbering modules
SendingsAbility=Support sendings sheets for customer deliveries
NoNeedForDeliveryReceipts=In most cases, sendings receipts are used both as sheets for customer deliveries (list of products to send) and sheets that is recevied and signed by customer. So product deliveries receipts is a duplicated feature and is rarely activated.
FreeLegalTextOnDeliveryReceipts=Free text on delivery receipts

View File

@ -1110,6 +1110,7 @@ NotificationEMailFrom=E-Mail emisor (From) de los correos enviados a través de
##### Sendings #####
SendingsSetup=Configuración del módulo Expediciones
SendingsReceiptModel=Modelo de notas de entrega
SendingsNumberingModules=Módulos de numeración de notas de entrega
SendingsAbility=Uso de notas de entrega para los envíos a clientes
NoNeedForDeliveryReceipts=En la mayoría de los casos, las notas de entrega (lista de productos enviados ) también actúan como notas de recepción y son firmadas por el cliente. La gestión de las notas de recepción es por lo tanto redundante y rara vez se activará.
FreeLegalTextOnDeliveryReceipts=Texto libre en las notas de recepción

View File

@ -1110,6 +1110,7 @@ NotificationEMailFrom=E-Mail emisor (From) de los correos enviados a través de
##### Sendings #####
SendingsSetup=Configuración del módulo Expediciones
SendingsReceiptModel=Modelo de notas de entrega
SendingsNumberingModules=Módulos de numeración de notas de entrega
SendingsAbility=Uso de notas de entrega para los envíos a clientes
NoNeedForDeliveryReceipts=En la mayoría de los casos, las notas de entrega (lista de productos enviados ) también actúan como notas de recepción y son firmadas por el cliente. La gestión de las notas de recepción es por lo tanto redundante y rara vez se activará.
FreeLegalTextOnDeliveryReceipts=Texto libre en las notas de recepción

View File

@ -1115,6 +1115,7 @@ NotificationEMailFrom= Email émetteur (From) des mails envoyés lors des notifi
##### Sendings #####
SendingsSetup= Configuration du module Expédition/Livraison
SendingsReceiptModel= Modèle du bordereau d'expédition
SendingsNumberingModules=Modèles de numérotation des expéditions
SendingsAbility= Prise en charge des bons d'expédition/livraison vers le client
NoNeedForDeliveryReceipts= Dans la plupart des cas, ce sont les bons d'expédition/livraison (liste des produits à envoyer par le transporteur) qui font office de bons de réception et qui sont signés par le client. La gestion des bons de réception fait donc double emploi et sera rarement activée.
FreeLegalTextOnDeliveryReceipts= Mention complémentaire sur les bons de réception