2004-10-19 20:58:50 +02:00
|
|
|
|
<?php
|
2005-04-03 17:37:59 +02:00
|
|
|
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2005-07-09 03:16:31 +02:00
|
|
|
|
* Copyright (C) 2004-2005 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>
|
2003-11-19 15:57:07 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*/
|
2004-08-29 14:01:58 +02:00
|
|
|
|
|
2005-04-06 00:02:26 +02:00
|
|
|
|
/**
|
2005-07-09 03:16:31 +02:00
|
|
|
|
\file htdocs/admin/expedition.php
|
|
|
|
|
|
\ingroup expedition
|
|
|
|
|
|
\brief Page d'administration/configuration du module Expedition
|
|
|
|
|
|
\version $Revision$
|
2004-08-29 14:01:58 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
2003-11-19 15:57:07 +01:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
|
2004-08-29 14:01:58 +02:00
|
|
|
|
$langs->load("admin");
|
2005-04-06 00:02:26 +02:00
|
|
|
|
$langs->load("sendings");
|
2004-08-29 14:01:58 +02:00
|
|
|
|
|
2005-04-03 17:37:59 +02:00
|
|
|
|
if (!$user->admin) accessforbidden();
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
// positionne la variable pour le test d'affichage de l'icone
|
|
|
|
|
|
$expedition_addon_var_pdf = EXPEDITION_ADDON_PDF;
|
|
|
|
|
|
$expedition_default = EXPEDITION_ADDON;
|
2005-04-06 00:02:26 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Actions
|
|
|
|
|
|
*/
|
2004-02-14 13:25:48 +01:00
|
|
|
|
if ($_GET["action"] == 'set')
|
2003-11-19 15:57:07 +01:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$file = DOL_DOCUMENT_ROOT . '/expedition/mods/methode_expedition_'.$_GET["value"].'.modules.php';
|
|
|
|
|
|
|
|
|
|
|
|
$classname = 'methode_expedition_'.$_GET["value"];
|
|
|
|
|
|
require_once($file);
|
|
|
|
|
|
|
|
|
|
|
|
$obj = new $classname($db);
|
|
|
|
|
|
|
|
|
|
|
|
$obj->Active($_GET["statut"]);
|
|
|
|
|
|
|
|
|
|
|
|
Header("Location: expedition.php");
|
2005-04-03 17:37:59 +02:00
|
|
|
|
}
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2004-07-27 10:15:12 +02:00
|
|
|
|
if ($_GET["action"] == 'setpdf')
|
2003-11-19 15:57:07 +01:00
|
|
|
|
{
|
2005-07-09 03:16:31 +02:00
|
|
|
|
$db->begin();
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON_PDF';";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2003-11-19 15:57:07 +01:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON_PDF','".$_GET["value"]."',0)";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
// la constante qui a <20>t<EFBFBD> lue en avant du nouveau set
|
|
|
|
|
|
// on passe donc par une variable pour avoir un affichage coh<6F>rent
|
|
|
|
|
|
$expedition_addon_var_pdf = $value;
|
|
|
|
|
|
|
|
|
|
|
|
$db->commit();
|
2005-07-09 03:16:31 +02:00
|
|
|
|
|
2005-07-31 11:16:53 +02:00
|
|
|
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
|
|
|
|
|
exit;
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
2005-07-31 11:16:53 +02:00
|
|
|
|
else
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$db->rollback();
|
|
|
|
|
|
dolibarr_print_error($db);
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2005-07-31 11:16:53 +02:00
|
|
|
|
{
|
2005-07-09 03:16:31 +02:00
|
|
|
|
$db->rollback();
|
|
|
|
|
|
dolibarr_print_error($db);
|
2005-07-31 11:16:53 +02:00
|
|
|
|
}
|
2003-11-19 15:57:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-02-14 13:25:48 +01:00
|
|
|
|
if ($_GET["action"] == 'setdef')
|
2003-11-19 15:57:07 +01:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$db->begin();
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON';";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON','".$_GET["value"]."',0)";
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
// la constante qui a <20>t<EFBFBD> lue en avant du nouveau set
|
|
|
|
|
|
// on passe donc par une variable pour avoir un affichage coh<6F>rent
|
|
|
|
|
|
$expedition_default = $_GET["value"];
|
|
|
|
|
|
$db->commit();
|
|
|
|
|
|
|
|
|
|
|
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
|
|
|
|
|
exit;
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
2005-07-31 11:16:53 +02:00
|
|
|
|
else
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$db->rollback();
|
|
|
|
|
|
dolibarr_print_error($db);
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2005-07-31 11:16:53 +02:00
|
|
|
|
else
|
2003-11-19 15:57:07 +01:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$db->rollback();
|
|
|
|
|
|
dolibarr_print_error($db);
|
2003-11-19 15:57:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."expedition_methode WHERE statut = 1";
|
|
|
|
|
|
$db->fetch_all_rows($sql, $mods);
|
2005-07-09 03:16:31 +02:00
|
|
|
|
|
2005-07-31 11:16:53 +02:00
|
|
|
|
llxHeader();
|
2005-07-09 03:16:31 +02:00
|
|
|
|
|
2005-04-09 10:59:20 +02:00
|
|
|
|
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
// M<>thode de livraison
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-04-06 00:02:26 +02:00
|
|
|
|
print_titre($langs->trans("SendingsSetup"));
|
2004-02-21 00:40:13 +01:00
|
|
|
|
|
|
|
|
|
|
print "<br>";
|
|
|
|
|
|
|
2005-04-06 00:02:26 +02:00
|
|
|
|
print_titre($langs->trans("SendingMethod"));
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print '<table class="noborder" width="100%">';
|
2003-11-19 15:57:07 +01:00
|
|
|
|
print '<tr class="liste_titre">';
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
2005-07-31 11:16:53 +02:00
|
|
|
|
print '<td align="center"> </td>';
|
|
|
|
|
|
print '<td align="center">'.$langs->trans("Active").'</td>';
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print '<td align="center">'.$langs->trans("Default").'</td>';
|
2003-11-19 15:57:07 +01:00
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
2004-09-10 21:30:08 +02:00
|
|
|
|
if(is_dir($dir)) {
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$handle=opendir($dir);
|
|
|
|
|
|
$var=true;
|
|
|
|
|
|
|
|
|
|
|
|
while (($file = readdir($handle))!==false)
|
2003-11-19 15:57:07 +01:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,19) == 'methode_expedition_')
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$name = substr($file, 19, strlen($file) - 31);
|
|
|
|
|
|
$classname = substr($file, 0, strlen($file) - 12);
|
|
|
|
|
|
|
|
|
|
|
|
require_once($dir.$file);
|
|
|
|
|
|
|
|
|
|
|
|
$obj = new $classname();
|
|
|
|
|
|
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr $bc[$var]><td>";
|
|
|
|
|
|
echo $obj->name;
|
|
|
|
|
|
print "</td><td>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print $obj->description;
|
|
|
|
|
|
|
|
|
|
|
|
print '</td><td align="center">';
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array($obj->id, $mods))
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_tick();
|
|
|
|
|
|
print '</td><td align="center">';
|
|
|
|
|
|
print '<a href="expedition.php?action=set&statut=0&value='.$name.'">'.$langs->trans("Disable").'</a>';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print ' </td><td align="center">';
|
|
|
|
|
|
print '<a href="expedition.php?action=set&statut=1&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print '</td>';
|
2005-07-09 03:16:31 +02:00
|
|
|
|
|
2005-07-31 11:16:53 +02:00
|
|
|
|
// Default
|
|
|
|
|
|
print '<td align="center">';
|
|
|
|
|
|
if ($expedition_default == "$name")
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
print img_tick();
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
2005-07-31 11:16:53 +02:00
|
|
|
|
else
|
2005-07-09 03:16:31 +02:00
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
print '<a href="expedition.php?action=setdef&value='.$name.'">'.$langs->trans("Default").'</a>';
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
2005-07-31 11:16:53 +02:00
|
|
|
|
print '</td>';
|
|
|
|
|
|
print '</tr>';
|
2005-07-09 03:16:31 +02:00
|
|
|
|
}
|
2003-11-19 15:57:07 +01:00
|
|
|
|
}
|
2005-07-09 03:16:31 +02:00
|
|
|
|
closedir($handle);
|
2004-09-10 21:30:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
2003-11-19 15:57:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
2004-02-21 00:40:13 +01:00
|
|
|
|
print '<br>';
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
// PDF
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-04-06 00:02:26 +02:00
|
|
|
|
print_titre($langs->trans("SendingsReceiptModel"));
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print '<table class="noborder" width="100%">';
|
2003-11-19 15:57:07 +01:00
|
|
|
|
print '<tr class="liste_titre">';
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
2005-04-06 00:02:26 +02:00
|
|
|
|
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
|
2003-11-19 15:57:07 +01:00
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
clearstatcache();
|
|
|
|
|
|
|
2005-04-09 10:59:20 +02:00
|
|
|
|
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/";
|
|
|
|
|
|
|
2005-04-03 17:37:59 +02:00
|
|
|
|
if(is_dir($dir))
|
|
|
|
|
|
{
|
2005-07-31 11:16:53 +02:00
|
|
|
|
$handle=opendir($dir);
|
|
|
|
|
|
$var=true;
|
|
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
while (($file = readdir($handle))!==false)
|
2005-07-31 11:16:53 +02:00
|
|
|
|
{
|
2005-07-09 03:16:31 +02:00
|
|
|
|
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_')
|
2005-07-31 11:16:53 +02:00
|
|
|
|
{
|
2005-07-09 03:16:31 +02:00
|
|
|
|
$name = substr($file, 15, strlen($file) - 27);
|
|
|
|
|
|
$classname = substr($file, 0, strlen($file) - 12);
|
2005-07-31 11:16:53 +02:00
|
|
|
|
|
2005-07-09 03:16:31 +02:00
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr $bc[$var]><td>";
|
|
|
|
|
|
print $name;
|
|
|
|
|
|
print "</td><td>\n";
|
|
|
|
|
|
require_once($dir.$file);
|
|
|
|
|
|
$obj = new $classname();
|
|
|
|
|
|
|
|
|
|
|
|
print $obj->description;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '</td><td align="center">';
|
|
|
|
|
|
|
|
|
|
|
|
if ($expedition_addon_var_pdf == "$name")
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_tick();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print " ";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "</td><td>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print '<a href="expedition.php?action=setpdf&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
}
|
2003-11-19 15:57:07 +01:00
|
|
|
|
}
|
2005-07-09 03:16:31 +02:00
|
|
|
|
closedir($handle);
|
2004-09-10 21:30:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-07-09 03:16:31 +02:00
|
|
|
|
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
2003-11-19 15:57:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-07-09 03:16:31 +02:00
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2003-11-19 15:57:07 +01:00
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter();
|
|
|
|
|
|
?>
|