*
* 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 3 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, see .
*/
/**
* \file htdocs/printipp/admin/printipp.php
* \ingroup core
* \brief Page to setup printipp module
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
require_once DOL_DOCUMENT_ROOT.'/printipp/lib/printipp.lib.php';
$langs->load("admin");
$langs->load("printipp");
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha');
if (!$mode) $mode='config';
/*
* Action
*/
if ($action == 'setvalue' && $user->admin)
{
$db->begin();
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PRINTIPP_HOST",GETPOST('PRINTIPP_HOST','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PRINTIPP_PORT",GETPOST('PRINTIPP_PORT','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PRINTIPP_USER",GETPOST('PRINTIPP_USER','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PRINTIPP_PASSWORD",GETPOST('PRINTIPP_PASSWORD','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
dol_print_error($db);
}
}
/*
* View
*/
$form = new Form($db);
llxHeader('',$langs->trans("PrintIPPSetup"));
$linkback=''.$langs->trans("BackToModuleList").'';
print_fiche_titre($langs->trans("PrintIPPSetup"),$linkback,'setup');
$head=printippadmin_prepare_head();
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"));
print $langs->trans("PrintIPPDesc")."
\n";
print '
';
if ($mode=='config'&& $user->admin)
{
print '
';
}
if ($mode=='test'&& $user->admin)
{
print '';
$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
$var=true;
print '';
print '';
print '| Uri | ';
print 'Name | ';
print 'State | ';
print 'State_reason | ';
print 'State_reason1 | ';
print 'BW | ';
print 'Color | ';
//print 'Device | ';
print 'Media | ';
print 'Supported | ';
print "
\n";
$list = $printer->getlist_available_printers();
$var = True;
foreach ($list as $value )
{
$var=!$var;
$printer_det = $printer->get_printer_detail($value);
print "";
print '| '.$value.' | ';
//print ''.print_r($printer_det,true).' | ';
print ''.$printer_det->printer_name->_value0.' | ';
print ''.$printer_det->printer_state->_value0.' | ';
print ''.$printer_det->printer_state_reasons->_value0.' | ';
print ''.$printer_det->printer_state_reasons->_value1.' | ';
print ''.$printer_det->printer_type->_value2.' | ';
print ''.$printer_det->printer_type->_value3.' | ';
//print ''.$printer_det->device_uri->_value0.' | ';
print ''.$printer_det->media_default->_value0.' | ';
print ''.$printer_det->media_type_supported->_value1.' | ';
print "
\n";
}
print '
';
if (count($list) == 0) print $langs->trans("NoPrinterFound");
}
dol_fiche_end();
llxFooter();
$db->close();
?>