These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * oledrion |
||
14 | * |
||
15 | * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
||
16 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
||
17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
18 | * @version $Id: invoice.php 12290 2014-02-07 11:05:17Z beckmi $ |
||
19 | */ |
||
20 | |||
21 | require 'header.php'; |
||
22 | $GLOBALS['current_category'] = -1; |
||
23 | |||
24 | $op = (isset($_GET['op'])) ? $_GET['op'] : 'default'; |
||
25 | |||
26 | View Code Duplication | if (isset($_GET['id'])) { |
|
27 | $cmdId = intval($_GET['id']); |
||
28 | } else { |
||
29 | oledrion_utils::redirect(_OLEDRION_ERROR11, 'index.php', 6); |
||
30 | } |
||
31 | |||
32 | View Code Duplication | if (isset($_GET['pass'])) { |
|
33 | $pass = $_GET['pass']; |
||
34 | } else { |
||
35 | if (!oledrion_utils::isAdmin()) { |
||
36 | oledrion_utils::redirect(_OLEDRION_ERROR11, 'index.php', 6); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | $order = null; |
||
41 | $order = $h_oledrion_commands->get($cmdId); |
||
42 | if (!is_object($order)) { |
||
43 | oledrion_utils::redirect(_OLEDRION_ERROR11, 'index.php', 6); |
||
44 | } |
||
45 | |||
46 | // Vérification du mot de passe (si pas admin) |
||
47 | if (!oledrion_utils::isAdmin()) { |
||
48 | if ($pass != $order->getVar('cmd_password')) { |
||
49 | oledrion_utils::redirect(_OLEDRION_ERROR11, 'index.php', 6); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | // Vérification de la validité de la facture (si pas admin) |
||
0 ignored issues
–
show
|
|||
54 | /* if (!oledrion_utils::isAdmin()) { |
||
55 | if ($order->getVar('cmd_state') != OLEDRION_STATE_VALIDATED) { // Commande non validée |
||
56 | oledrion_utils::redirect(_OLEDRION_ERROR12, 'index.php', 6); |
||
57 | } |
||
58 | } */ |
||
59 | |||
60 | $caddy = $tmp = $products = $vats = $manufacturers = $tmp2 = $manufacturers = $productsManufacturers = array(); |
||
61 | |||
62 | // Récupération des TVA |
||
63 | $vats = $h_oledrion_vat->getAllVats(new oledrion_parameters()); |
||
64 | |||
65 | // Récupération des caddy associés |
||
66 | $caddy = $h_oledrion_caddy->getCaddyFromCommand($cmdId); |
||
67 | if (count($caddy) == 0) { |
||
68 | oledrion_utils::redirect(_OLEDRION_ERROR11, 'index.php', 6); |
||
69 | } |
||
70 | |||
71 | // Récupération de la liste des produits associés |
||
72 | foreach ($caddy as $item) { |
||
73 | $tmp[] = $item->getVar('caddy_product_id'); |
||
74 | } |
||
75 | |||
76 | // Recherche des produits *********************************************************************************************** |
||
77 | $products = $h_oledrion_products->getProductsFromIDs($tmp, true); |
||
78 | |||
79 | // Recherche des fabricants ********************************************************************************************** |
||
80 | $tmp2 = $h_oledrion_productsmanu->getFromProductsIds($tmp); |
||
81 | $tmp = array(); |
||
82 | View Code Duplication | foreach ($tmp2 as $item) { |
|
83 | $tmp[] = $item->getVar('pm_manu_id'); |
||
84 | $productsManufacturers[$item->getVar('pm_product_id')][] = $item; |
||
85 | } |
||
86 | $manufacturers = $h_oledrion_manufacturer->getManufacturersFromIds($tmp); |
||
87 | |||
88 | switch ($op) { |
||
89 | case 'print': |
||
90 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
91 | |||
92 | // Informations sur la commande *************************************************************************************** |
||
93 | $xoopsTpl->assign('order', $order->toArray()); |
||
94 | $xoopsTpl->assign('ask_vatnumber', oledrion_utils::getModuleOption('ask_vatnumber')); |
||
95 | $handlers = oledrion_handler::getInstance(); |
||
96 | |||
97 | // Boucle sur le caddy ************************************************************************************************ |
||
98 | View Code Duplication | foreach ($caddy as $itemCaddy) { |
|
99 | $productForTemplate = $tblJoin = $productManufacturers = $productAttributes = array(); |
||
100 | $product = $products[$itemCaddy->getVar('caddy_product_id')]; |
||
101 | $productForTemplate = $product->toArray(); // Produit |
||
102 | // Est-ce qu'il y a des attributs ? |
||
103 | if ($handlers->h_oledrion_caddy_attributes->getAttributesCountForCaddy($itemCaddy->getVar('caddy_id')) > 0) { |
||
104 | $productAttributes = $handlers->h_oledrion_caddy_attributes->getFormatedAttributesForCaddy($itemCaddy->getVar('caddy_id'), $product); |
||
105 | } |
||
106 | $productForTemplate['product_attributes'] = $productAttributes; |
||
107 | |||
108 | $productManufacturers = $productsManufacturers[$product->getVar('product_id')]; |
||
109 | foreach ($productManufacturers as $oledrion_productsmanu) { |
||
110 | if (isset($manufacturers[$oledrion_productsmanu->getVar('pm_manu_id')])) { |
||
111 | $manufacturer = $manufacturers[$oledrion_productsmanu->getVar('pm_manu_id')]; |
||
112 | $tblJoin[] = $manufacturer->getVar('manu_commercialname') . ' ' . $manufacturer->getVar('manu_name'); |
||
113 | } |
||
114 | } |
||
115 | if (count($tblJoin) > 0) { |
||
116 | $productForTemplate['product_joined_manufacturers'] = implode(', ', $tblJoin); |
||
117 | } |
||
118 | $productForTemplate['product_caddy'] = $itemCaddy->toArray(); |
||
119 | $xoopsTpl->append('products', $productForTemplate); |
||
120 | } |
||
121 | // Display print page |
||
122 | echo $xoopsTpl->fetch(OLEDRION_PATH . '/templates/oledrion_bill_print.tpl'); |
||
123 | break; |
||
124 | |||
125 | case 'default': |
||
126 | default: |
||
127 | /** |
||
128 | * Visualisation d'une facture à l'écran |
||
129 | */ |
||
130 | $xoopsOption['template_main'] = 'oledrion_bill.tpl'; |
||
131 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
132 | |||
133 | // Informations sur la commande *************************************************************************************** |
||
134 | $xoopsTpl->assign('order', $order->toArray()); |
||
135 | $xoopsTpl->assign('ask_vatnumber', oledrion_utils::getModuleOption('ask_vatnumber')); |
||
136 | $xoopsTpl->assign('printurl', OLEDRION_URL . basename(__FILE__) . '?op=print&id=' . $order->getVar('cmd_id') . '&pass=' . $order->getVar('cmd_password')); |
||
137 | |||
138 | $handlers = oledrion_handler::getInstance(); |
||
139 | |||
140 | // Boucle sur le caddy ************************************************************************************************ |
||
141 | View Code Duplication | foreach ($caddy as $itemCaddy) { |
|
142 | $productForTemplate = $tblJoin = $productManufacturers = $productAttributes = array(); |
||
143 | $product = $products[$itemCaddy->getVar('caddy_product_id')]; |
||
144 | $productForTemplate = $product->toArray(); // Produit |
||
145 | // Est-ce qu'il y a des attributs ? |
||
146 | if ($handlers->h_oledrion_caddy_attributes->getAttributesCountForCaddy($itemCaddy->getVar('caddy_id')) > 0) { |
||
147 | $productAttributes = $handlers->h_oledrion_caddy_attributes->getFormatedAttributesForCaddy($itemCaddy->getVar('caddy_id'), $product); |
||
148 | } |
||
149 | $productForTemplate['product_attributes'] = $productAttributes; |
||
150 | |||
151 | $productManufacturers = $productsManufacturers[$product->getVar('product_id')]; |
||
152 | foreach ($productManufacturers as $oledrion_productsmanu) { |
||
153 | if (isset($manufacturers[$oledrion_productsmanu->getVar('pm_manu_id')])) { |
||
154 | $manufacturer = $manufacturers[$oledrion_productsmanu->getVar('pm_manu_id')]; |
||
155 | $tblJoin[] = $manufacturer->getVar('manu_commercialname') . ' ' . $manufacturer->getVar('manu_name'); |
||
156 | } |
||
157 | } |
||
158 | if (count($tblJoin) > 0) { |
||
159 | $productForTemplate['product_joined_manufacturers'] = implode(', ', $tblJoin); |
||
160 | } |
||
161 | $productForTemplate['product_caddy'] = $itemCaddy->toArray(); |
||
162 | $xoopsTpl->append('products', $productForTemplate); |
||
163 | } |
||
164 | |||
165 | oledrion_utils::setCSS(); |
||
166 | oledrion_utils::setLocalCSS($xoopsConfig['language']); |
||
167 | $title = _OLEDRION_BILL . ' - ' . oledrion_utils::getModuleName(); |
||
168 | oledrion_utils::setMetas($title, $title); |
||
169 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
170 | break; |
||
171 | } |
||
172 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.