1<?php
2/* Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@inodbox.com>
4 * Copyright (C) 2006      Andre Cianfarani     <acianfa@free.fr>
5 * Copyright (C) 2011-2016 Juanjo Menent		<jmenent@2byte.es>ù
6 * Copyright (C) 2015      Claudio Aschieri     <c.aschieri@19.coop>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22/**
23 *	    \file       htdocs/admin/confexped.php
24 *		\ingroup    produit
25 *		\brief      Page to setup sending module
26 */
27
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
31
32// Load translation files required by the page
33$langs->loadLangs(array('admin', 'sendings', 'deliveries'));
34
35if (!$user->admin)
36  accessforbidden();
37
38$action = GETPOST('action', 'aZ09');
39
40
41/*
42 * Actions
43 */
44
45// Shipment note
46if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
47{
48	// This option should always be set to on when module is on.
49	dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
50}
51/*
52if ($action == 'activate_sending')
53{
54    dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);
55    header("Location: confexped.php");
56    exit;
57}
58if ($action == 'disable_sending')
59{
60	dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity);
61    header("Location: confexped.php");
62    exit;
63}
64*/
65
66// Delivery note
67if ($action == 'activate_delivery')
68{
69	dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this
70	dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity);
71	header("Location: confexped.php");
72	exit;
73} elseif ($action == 'disable_delivery')
74{
75	dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity);
76	header("Location: confexped.php");
77	exit;
78}
79
80
81/*
82 * View
83 */
84
85$dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/";
86$form = new Form($db);
87
88llxHeader("", $langs->trans("SendingsSetup"));
89
90$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
91print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup');
92print '<br>';
93$head = expedition_admin_prepare_head();
94
95print dol_get_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'shipment');
96
97// Miscellaneous parameters
98
99print '<table class="noborder centpercent">';
100print '<tr class="liste_titre">';
101print '<td>'.$langs->trans("Feature").'</td>';
102print '<td width="20">&nbsp;</td>';
103print '<td class="center">'.$langs->trans("Status").'</td>';
104print '</tr>'."\n";
105
106// expedition activation/desactivation
107print "<tr>";
108print '<td>'.$langs->trans("SendingsAbility").'</td>';
109print '<td>';
110print '</td>';
111print '<td class="center">';
112print $langs->trans("Required");
113/*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
114{
115	print '<a href="confexped.php?action=activate_sending">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
116}
117else
118{
119	print '<a href="confexped.php?action=disable_sending">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
120}*/
121print "</td>";
122print '</tr>';
123
124// Delivery note activate/deactivate Bon de livraison activation/desactivation
125print '<tr>';
126print '<td>';
127print $langs->trans("DeliveriesOrderAbility");
128print '<br>'.info_admin($langs->trans("NoNeedForDeliveryReceipts"), 0, 1);
129print '</td>';
130print '<td>';
131print '</td>';
132print '<td class="center">';
133
134if (empty($conf->global->MAIN_SUBMODULE_DELIVERY))
135{
136	print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
137} else {
138	print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
139}
140
141print "</td>";
142print '</tr>';
143print '</table>';
144
145print '</div>';
146
147// End of page
148llxFooter();
149$db->close();
150