Merge branch 'develop' of git+ssh://git@github.com/Dolibarr/dolibarr.git into task498_objectline

This commit is contained in:
Regis Houssin 2012-08-25 11:28:08 +02:00
commit 6fe631378b
8 changed files with 114 additions and 194 deletions

View File

@ -1,12 +1,12 @@
<?php
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.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
@ -37,7 +37,8 @@ $langs->load("sendings");
$langs->load("deliveries");
$langs->load('other');
if (!$user->admin) accessforbidden();
if (! $user->admin)
accessforbidden();
$action=GETPOST('action','alpha');
$value=GETPOST('value','alpha');
@ -54,60 +55,45 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
/*
* Actions
*/
if ($action == 'updateMask')
if ($action == 'updateMask')
{
$maskconst=GETPOST('maskconstexpedition','alpha');
$maskvalue=GETPOST('maskexpedition','alpha');
if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (! empty($maskconst))
$res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
if (isset($res))
{
if ($res < 0)
setEventMessage($langs->trans("SetupSaved"));
else
setEventMessage($langs->trans("Error"), 'errors');
}
}
if ($action == 'set_SHIPPING_FREE_TEXT')
else if ($action == 'set_SHIPPING_FREE_TEXT')
{
$freetext=GETPOST('SHIPPING_FREE_TEXT','alpha');
$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
if ($res < 0)
setEventMessage($langs->trans("SetupSaved"));
else
setEventMessage($langs->trans("Error"), 'errors');
}
if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
{
$draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
if ($res < 0)
setEventMessage($langs->trans("SetupSaved"));
else
setEventMessage($langs->trans("Error"), 'errors');
}
if ($action == 'specimen')
else if ($action == 'specimen')
{
$modele=GETPOST('module','alpha');
@ -141,24 +127,24 @@ if ($action == 'specimen')
}
else
{
$mesg='<font class="error">'.$module->error.'</font>';
setEventMessage($module->error, 'errors');
dol_syslog($module->error, LOG_ERR);
}
}
else
{
$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
setEventMessage($langs->trans("ErrorModuleNotFound"), 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Activate a model
if ($action == 'set')
else if ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
if ($action == 'del')
else if ($action == 'del')
{
$ret = delDocumentModel($value, $type);
if ($ret > 0)
@ -167,105 +153,25 @@ if ($action == 'del')
}
}
// Set default model
if ($action == 'setdoc')
{
if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf->global->EXPEDITION_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
// Set default model
else if ($action == 'setdoc')
{
if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf->global->EXPEDITION_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
// TODO A quoi servent les methode d'expedition ?
if ($action == 'setmethod' || $action== 'setmod')
{
$module=GETPOST('module','alpha');
$moduleid=GETPOST('moduleid','alpha');
$statut=GETPOST('statut','alpha');
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_$module.modules.php";
$classname = "methode_expedition_$module";
$expem = new $classname($db);
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$sql.= " WHERE rowid = ".$moduleid;
$resql = $db->query($sql);
if ($resql && ($statut == 1 || $action == 'setmod'))
{
$db->begin();
$sqlu = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode";
$sqlu.= " SET statut=1";
$sqlu.= " WHERE rowid=".$moduleid;
$result=$db->query($sqlu);
if ($result)
{
$db->commit();
}
else
{
$db->rollback();
}
}
if ($statut == 1 || $action == 'setmod')
{
$db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (rowid,code,libelle,description,statut)";
$sql.= " VALUES (".$moduleid.",'".$expem->code."','".$expem->name."','".$expem->description."',1)";
$result=$db->query($sql);
if ($result)
{
$db->commit();
}
else
{
//dol_print_error($db);
$db->rollback();
}
}
else if ($statut == 0)
{
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode";
$sql.= " SET statut=0";
$sql.= " WHERE rowid=".$moduleid;
$result=$db->query($sql);
if ($result)
{
$db->commit();
}
else
{
$db->rollback();
}
}
}
if ($action == 'setmod')
{
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
dolibarr_set_const($db, "EXPEDITION_ADDON",$value,'chaine',0,'',$conf->entity);
}
if ($action == 'setmodel')
else if ($action == 'setmodel')
{
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
}
@ -489,10 +395,10 @@ foreach ($dirmodels as $reldir)
// Active
if (in_array($name, $def))
{
print "<td align=\"center\">\n";
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a>';
print '</a>';
print "</td>";
}
else
@ -577,9 +483,7 @@ print '</form>';
print '</table>';
dol_htmloutput_mesg($mesg);
$db->close();
llxFooter();
$db->close();
?>

View File

@ -3,6 +3,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2008 Chiptronik
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.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
@ -142,8 +143,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (file_exists($dir))
{
$pdf=pdf_getInstance($this->format);
$heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin)
$heightforinfotot = 50; // Height reserved to output the info and total part (value include bottom margin)
$heightforfooter = 50; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF'))
@ -205,8 +206,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0,0,0);
$tab_top = 90;
$tab_top_newpage = 50;
$tab_height = 110;
$tab_top_newpage = 5;
$tab_height = 150;
$tab_height_newpage = 150;
// Affiche notes
@ -242,7 +243,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot-50); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description de la ligne produit
@ -253,7 +254,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY();
$nexY = $pdf->GetY()+4;
/*
// TVA

View File

@ -84,11 +84,11 @@ class modExpedition extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "EXPEDITION_ADDON";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "elevement";
$this->const[$r][3] = 'Nom du gestionnaire du type d\'expedition';
$this->const[$r][4] = 0;
$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++;
$this->const[$r][0] = "LIVRAISON_ADDON_PDF";
@ -105,13 +105,6 @@ class modExpedition extends DolibarrModules
$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();
@ -211,8 +204,8 @@ class modExpedition extends DolibarrModules
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','shipping',".$conf->entity.")",
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[1][2]."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[1][2]."','delivery',".$conf->entity.")",
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[2][2]."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[2][2]."','delivery',".$conf->entity.")",
);
return $this->_init($sql,$options);

View File

@ -5,6 +5,7 @@
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2012 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.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
@ -1840,6 +1841,43 @@ class CommandeFournisseur extends CommonOrder
return -1;
}
}
/**
* Returns the translated input method
*
* @return string
*/
function getInputMethod()
{
global $db, $langs;
if ($this->methode_commande_id > 0)
{
$sql = "SELECT rowid, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method';
$sql.= " WHERE active=1 AND rowid = ".$db->escape($this->methode_commande_id);
$query = $db->query($sql);
if ($query && $db->num_rows($query))
{
$result = $db->fetch_object($query);
$string = $langs->trans($result->code);
if ($string == $result->code)
{
$string = $obj->libelle != '-' ? $obj->libelle : '';
}
return $string;
}
dol_print_error($db);
}
return '';
}
}

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.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
@ -160,7 +161,7 @@ if ($object->id > 0)
if ($object->methode_commande)
{
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->methode_commande.'</td></tr>';
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>';
}
}

View File

@ -1120,25 +1120,7 @@ if ($id > 0 || ! empty($ref))
if ($object->methode_commande)
{
$sql = "SELECT rowid, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method';
$sql.= " WHERE active=1 AND rowid = ".$db->escape($object->methode_commande_id);
$resql = $db->query($sql);
if ($resql && $db->num_rows($resql))
{
$obj = $db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$methode_commande = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->libelle!='-'?$obj->libelle:''));
}
else
{
dol_print_error($db);
}
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$methode_commande.'</td></tr>';
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>';
}
}

View File

@ -109,7 +109,7 @@ if ($id > 0 || ! empty($ref))
if ($commande->methode_commande)
{
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$commande->methode_commande.'</td></tr>';
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$commande->getInputMethod().'</td></tr>';
}
}

View File

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.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
@ -130,7 +131,7 @@ if ($id > 0 || ! empty($ref))
if ($object->methode_commande)
{
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->methode_commande.'</td></tr>';
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>';
}
}