providers.php 4.21 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
//    Pastèque Web back office, Products module
//
//    Copyright (C) 2013 Scil (http://scil.coop)
//
//    This file is part of Pastèque.
//
//    Pastèque 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 3 of the License, or
//    (at your option) any later version.
//
//    Pastèque 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 Pastèque.  If not, see <http://www.gnu.org/licenses/>.

// providers action

namespace BaseProducts;

$message = NULL;
$error = NULL;
if (isset($_POST['delete-prov'])) {
    if (\Pasteque\providersService::deleteprov($_POST['delete-prov'])) {
        $message = \i18n("Changes saved");
    } else {
        $error = \i18n("Unable to save changes");
        $error .= " " . \i18n("Only empty provider can be deleted", PLUGIN_NAME);
    }
}

$providers = \Pasteque\providersService::getAll();
?>

39
40
41
<div class="blc_ti">
    <h1><?php \pi18n("Providers", PLUGIN_NAME); ?></h1>
    <span class="nb_article"><?php \pi18n("%d providers", PLUGIN_NAME, count($providers)); ?></span>
42

43
    <?php \Pasteque\tpl_msg_box($message, $error); ?>
44

45
46
47
48
49
    <ul class="bt_fonction">
            <li><?php \Pasteque\tpl_btn('btn', \Pasteque\get_module_url_action(PLUGIN_NAME, "provider_edit"),
        \i18n('Add a provider', PLUGIN_NAME), 'img/btn_add.png');?></li>
            <li><?php \Pasteque\tpl_btn('btn', \Pasteque\get_module_url_action(PLUGIN_NAME, "providersManagement"),
        \i18n('Import providers', PLUGIN_NAME), 'img/btn_add.png');?></li>
Julien Fastré's avatar
Julien Fastré committed
50
51
            <li><?php \Pasteque\tpl_btn('btn bt_export ', \Pasteque\get_report_url(PLUGIN_NAME, "providers_export"),
            \i18n('Export Providers', PLUGIN_NAME), 'img/btn_add.png');?></li>
52
53
    </ul>
</div>
54

55
56
57
58
59

<div class="container_scroll">
    <div class="stick_row stickem-container">
        <div id="content_liste" class="grid_9">
            <div class="blc_content">
60
61
62
63
64

<table cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th></th>
65
			<th><?php \pi18n("Provider.label"); ?></th>
66
67
68
69
70
			<th></th>
		</tr>
	</thead>
	<tbody>
<?php
71
function printprovider($printprovider, $level, &$par) {
72
73
        $par = !$par;
        if ($printprovider->hasImage) {
74
            $imgSrc = \Pasteque\PT::URL_ACTION_PARAM . "=img&w=provider&id=" . $printprovider->id;
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
        } else {
            $imgSrc = \Pasteque\PT::URL_ACTION_PARAM . "=img&w=provider";
        }
        ?>
                <tr class="row-<?php echo $par ? 'par' : 'odd'; ?>">
                        <td>
                        <?php
                        for($i=0;$i<$level;$i++) {
                            echo "&nbsp;&nbsp;&nbsp;&nbsp;";
                        }
                        ?>
                        <img class="thumbnail" src="?<?php echo $imgSrc ?>" />
                        <td><?php echo $printprovider->label; ?></td>
                        <td class="edition">
                    <?php \Pasteque\tpl_btn("edition", \Pasteque\get_module_url_action(PLUGIN_NAME,
90
                            'provider_edit', array("id" => $printprovider->id)), "",
91
92
93
94
95
96
97
98
99
100
                            'img/edit.png', \i18n('Edit'), \i18n('Edit'));
                    ?>
                                <form action="<?php echo \Pasteque\get_current_url(); ?>" method="post"><?php \Pasteque\form_delete("prov", $printprovider->id, \Pasteque\get_template_url() . 'img/delete.png') ?></form>
                        </td>
                </tr>
        <?php
}

$par = false;
foreach ($providers as $provider) {
101
    printprovider($provider, 0, $par);
102
103
104
105
106
107
108
}
?>
	</tbody>
</table>
<?php
if (count($providers) == 0) {
?>
109
            <div class="alert"><?php \pi18n("No provider found", PLUGIN_NAME); ?></div>
110
111
112
<?php
}
?>
113
114
115
116
117
118
119
120
121
            </div>
        </div>
        <div id="sidebar_menu" class="grid_3 stickem">
            <div class="blc_content">
                <div class="edito"><!-- zone_edito --></div>
            </div>
        </div>
    </div>
</div>