function plugin_barcode_MassiveActionsProcess($data) { global $CFG_GLPI; switch ($data['action']) { case 'plugin_barcode_barcode': case 'plugin_barcode_qrcode': $pbConfig = new PluginBarcodeConfig(); $pbQRcode = new PluginBarcodeQRcode(); $itemtype = $data['itemtype']; $item = new $itemtype(); $rand = mt_rand(); $number = 0; $codes = array(); if ($data['eliminate'] > 0) { for ($nb = 0; $nb < $data['eliminate']; $nb++) { $codes[] = ''; } } if ($data['type'] == 'QRcode') { foreach ($data['item'] as $key => $val) { if ($val == 1) { $filename = $pbQRcode->generateQRcode($itemtype, $key, $rand, $number, $data); if ($filename) { $codes[] = $filename; $number++; } } } } else { foreach ($data['item'] as $key => $val) { if ($val == 1) { $item->getFromDB($key); if ($item->isField('otherserial')) { $codes[] = $item->getField('otherserial'); } } } } if (count($codes) > 0) { $params['codes'] = $codes; $params['type'] = $data['type']; $params['size'] = $data['size']; $params['border'] = $data['border']; $params['orientation'] = $data['orientation']; $barcode = new PluginBarcodeBarcode(); $file = $barcode->printPDF($params); $filePath = explode('/', $file); $filename = $filePath[count($filePath) - 1]; $msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>"; Session::addMessageAfterRedirect($msg); $pbQRcode->cleanQRcodefiles($rand, $number); } return true; break; case "plugin_barcode_allow": $profglpi = new Profile(); $prof = new PluginBarcodeProfile(); foreach ($data['item'] as $key => $val) { if ($profglpi->getFromDB($key) && $profglpi->fields['interface'] != 'helpdesk') { if ($prof->getFromDB($key)) { $prof->update(array('id' => $key, 'generate' => $data['generate'], 'config' => $data['config'])); } else { if ($data['generate']) { $prof->add(array('id' => $key, 'generate' => $data['generate'])); } else { if ($data['config']) { $prof->add(array('id' => $key, 'config' => $data['config'])); } } } } } break; } }
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $CFG_GLPI; switch ($ma->getAction()) { case 'Generate': $pbQRcode = new PluginBarcodeQRcode(); $rand = mt_rand(); $number = 0; $codes = array(); if ($ma->POST['eliminate'] > 0) { for ($nb = 0; $nb < $ma->POST['eliminate']; $nb++) { $codes[] = ''; } } if ($ma->POST['type'] == 'QRcode') { foreach ($ids as $key) { $filename = $pbQRcode->generateQRcode($item->getType(), $key, $rand, $number, $ma->POST); if ($filename) { $codes[] = $filename; $number++; } } } else { foreach ($ids as $key) { $item->getFromDB($key); if ($item->isField('otherserial')) { $codes[] = $item->getField('otherserial'); } } } if (count($codes) > 0) { $params['codes'] = $codes; $params['type'] = $ma->POST['type']; $params['size'] = $ma->POST['size']; $params['border'] = $ma->POST['border']; $params['orientation'] = $ma->POST['orientation']; $barcode = new PluginBarcodeBarcode(); $file = $barcode->printPDF($params); $filePath = explode('/', $file); $filename = $filePath[count($filePath) - 1]; $msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>"; Session::addMessageAfterRedirect($msg); $pbQRcode->cleanQRcodefiles($rand, $number); } $ma->itemDone($item->getType(), 0, MassiveAction::ACTION_OK); return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }