Fixed a lot of bugs into PrintIPP module. Seems to be stable enough now

for release.
This commit is contained in:
Laurent Destailleur 2014-12-04 13:20:56 +01:00
parent ec9c3cc115
commit 83122ebe1e
35 changed files with 190 additions and 107 deletions

View File

@ -249,7 +249,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup');
print '<br>';
$head = order_admin_prepare_head(null);
$head = order_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Orders"), 0, 'order');

View File

@ -296,7 +296,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
print '<br>';
$head = invoice_admin_prepare_head(null);
$head = invoice_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Invoices"), 0, 'invoice');
/*

View File

@ -73,7 +73,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup');
print "<br>\n";
$head = order_admin_prepare_head(null);
$head = order_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Orders"), 0, 'order');

View File

@ -74,7 +74,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup');
print "<br>\n";
$head = order_admin_prepare_head(null);
$head = order_admin_prepare_head();
dol_fiche_head($head, 'attributeslines', $langs->trans("Orders"), 0, 'order');

View File

@ -263,7 +263,7 @@ $form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
$head = propal_admin_prepare_head(null);
$head = propal_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Proposals"), 0, 'propal');
@ -602,7 +602,7 @@ if ($conf->banque->enabled)
{
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp</td><td align="center">';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp</td><td align="right">';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL');

View File

@ -198,7 +198,7 @@ print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
print "<br>";
$head = supplierorder_admin_prepare_head(null);
$head = supplierorder_admin_prepare_head();
dol_fiche_head($head, 'invoice', $langs->trans("Suppliers"), 0, 'company');

View File

@ -199,7 +199,7 @@ print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
print "<br>";
$head = supplierorder_admin_prepare_head(null);
$head = supplierorder_admin_prepare_head();
dol_fiche_head($head, 'order', $langs->trans("Suppliers"), 0, 'company');

View File

@ -75,7 +75,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
print "<br>\n";
$head = supplierorder_admin_prepare_head(null);
$head = supplierorder_admin_prepare_head();
dol_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), 0, 'company');

View File

@ -73,7 +73,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
print "<br>\n";
$head = supplierorder_admin_prepare_head(null);
$head = supplierorder_admin_prepare_head();
dol_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), 0, 'company');

View File

@ -69,7 +69,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
$head = propal_admin_prepare_head(null);
$head = propal_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Proposals"), 0, 'propal');

View File

@ -74,7 +74,7 @@ llxHeader('',$langs->trans("PropalSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
$head = propal_admin_prepare_head(null);
$head = propal_admin_prepare_head();
dol_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), 0, 'propal');

View File

@ -553,6 +553,8 @@ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST(
}
}
include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php';
/*
* Send mail

View File

@ -1115,15 +1115,6 @@ else if ($action == 'remove_file') {
}
}
// Print file
else if ($action == 'print_file' and $user->rights->printipp->read) {
require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php';
$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD);
$printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'));
setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file')));
$action = '';
}
else if ($action == 'update_extras') {
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
@ -1151,6 +1142,9 @@ else if ($action == 'update_extras') {
$action = 'edit_extras';
}
include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php';
/*
* Send mail
*/

View File

@ -1615,14 +1615,7 @@ else if ($action == 'remove_file') {
}
}
// Print file
else if ($action == 'print_file' and $user->rights->printipp->read) {
require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php';
$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD);
$printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'));
setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file')));
$action = '';
}
include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
{

View File

@ -70,7 +70,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
print '<br>';
$head = invoice_admin_prepare_head(null);
$head = invoice_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice');

View File

@ -71,7 +71,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
print '<br>';
$head = invoice_admin_prepare_head(null);
$head = invoice_admin_prepare_head();
dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice');

View File

@ -0,0 +1,45 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_printipp.inc.php
* \brief Code for actions print_file to print file using ipp
*/
// $action must be defined
// $db, $user, $conf, $langs must be defined
// Filename to print must be provided into 'file' parameter
// Print file
if ($action == 'print_file' and $user->rights->printipp->read)
{
$langs->load("printipp");
require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php';
$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD);
$result = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'));
if ($result)
{
setEventMessage($result,'warnings');
}
else
{
setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))));
}
$action = '';
}

View File

@ -253,7 +253,7 @@ class DolGraph
/**
* Set legend
*
* @param string $legend Legend
* @param array $legend Legend. Example: array('seriename1','seriname2',...)
* @return void
*/
function SetLegend($legend)

View File

@ -83,19 +83,22 @@ class dolprintIPP
* @param string $file file
* @param string $module module
*
* @return void
* @return string '' if OK, Error message if KO
*/
function print_file($file,$module)
function print_file($file, $module)
{
global $conf,$db;
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
$ipp = new CupsPrintIPP();
$ipp->setLog(DOL_DATA_ROOT.'/printipp.log','file',3); // logging very verbose
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
$ipp->setHost($this->host);
$ipp->setPort($this->port);
$ipp->setJobName($file,true);
$ipp->setUserName($this->userid);
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
// select printer uri for module order, propal,...
$sql = 'SELECT rowid,printer_uri,copy FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"';
$result = $this->db->query($sql);
@ -108,13 +111,23 @@ class dolprintIPP
}
else
{
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
if (! empty($conf->global->PRINTIPP_URI_DEFAULT))
{
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
}
else
{
return 'NoDefaultPrinterDefined';
}
}
}
// Set number of copy
$ipp->setCopies($obj->copy);
$ipp->setData(DOL_DATA_ROOT.'/'.$module.'/'.$file);
$ipp->printJob();
return '';
}
/**

View File

@ -270,7 +270,13 @@ class FormFile
if (! empty($iconPDF)) {
return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir);
}
$printer = (!empty($user->rights->printipp->read) && !empty($conf->printipp->enabled))?true:false;
$printer=0;
if (in_array($modulepart,array('facture','propal','proposal','order','commande'))) // This feature is implemented only for such elements
{
$printer = (!empty($user->rights->printipp->read) && !empty($conf->printipp->enabled))?true:false;
}
$hookmanager->initHooks(array('formfile'));
$forname='builddoc';
$out='';

View File

@ -52,7 +52,6 @@ if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path t
if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc=constant('PHP-BARCODE_PATH_COMMAND');
else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION;
//dol_syslog("genbarcode_loc=".$genbarcode_loc." - env_windows=".$_SERVER['WINDIR']);

View File

@ -217,10 +217,9 @@ function societe_prepare_head2($object)
/**
* Return array head with list of tabs to view object informations.
*
* @param Object $object Thirdparty
* @return array head array with tabs
*/
function societe_admin_prepare_head($object)
function societe_admin_prepare_head()
{
global $langs, $conf, $user;
@ -236,7 +235,7 @@ function societe_admin_prepare_head($object)
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin');
complete_head_from_modules($conf,$langs,null,$head,$h,'company_admin');
$head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsThirdParties");
@ -248,7 +247,7 @@ function societe_admin_prepare_head($object)
$head[$h][2] = 'attributes_contacts';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin','remove');
complete_head_from_modules($conf,$langs,null,$head,$h,'company_admin','remove');
return $head;
}

View File

@ -160,10 +160,9 @@ function ordersupplier_prepare_head($object)
/**
* Return array head with list of tabs to view object informations.
*
* @param Object $object order
* @return array head array with tabs
*/
function supplierorder_admin_prepare_head($object)
function supplierorder_admin_prepare_head()
{
global $langs, $conf, $user;
@ -180,7 +179,7 @@ function supplierorder_admin_prepare_head($object)
$head[$h][2] = 'invoice';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplierorder_admin');
complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin');
$head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
@ -192,7 +191,7 @@ function supplierorder_admin_prepare_head($object)
$head[$h][2] = 'supplierinvoice';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplierorder_admin','remove');
complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin','remove');
return $head;
}

View File

@ -4612,26 +4612,26 @@ function picto_from_langcode($codelang)
* Complete or removed entries into a head array (used to build tabs) with value added by external modules.
* Such values are declared into $conf->modules_parts['tab'].
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param Object $object Object object
* @param array $head Object head
* @param int $h New position to fill
* @param string $type Value for object where objectvalue can be
* 'thirdparty' to add a tab in third party view
* 'intervention' to add a tab in intervention view
* 'supplier_order' to add a tab in supplier order view
* 'supplier_invoice' to add a tab in supplier invoice view
* 'invoice' to add a tab in customer invoice view
* 'order' to add a tab in customer order view
* 'product' to add a tab in product view
* 'propal' to add a tab in propal view
* 'user' to add a tab in user view
* 'group' to add a tab in group view
* 'member' to add a tab in fundation member view
* 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member)
* 'ecm' to add a tab for another ecm view
* @param string $mode 'add' to complete head, 'remove' to remove entries
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param Object|null $object Object object
* @param array $head Object head
* @param int $h New position to fill
* @param string $type Value for object where objectvalue can be
* 'thirdparty' to add a tab in third party view
* 'intervention' to add a tab in intervention view
* 'supplier_order' to add a tab in supplier order view
* 'supplier_invoice' to add a tab in supplier invoice view
* 'invoice' to add a tab in customer invoice view
* 'order' to add a tab in customer order view
* 'product' to add a tab in product view
* 'propal' to add a tab in propal view
* 'user' to add a tab in user view
* 'group' to add a tab in group view
* 'member' to add a tab in fundation member view
* 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member)
* 'ecm' to add a tab for another ecm view
* @param string $mode 'add' to complete head, 'remove' to remove entries
* @return void
*/
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')

View File

@ -106,10 +106,9 @@ function facture_prepare_head($object)
/**
* Return array head with list of tabs to view object informations.
*
* @param Object $object Invoice
* @return array head array with tabs
*/
function invoice_admin_prepare_head($object)
function invoice_admin_prepare_head()
{
global $langs, $conf, $user;
@ -125,7 +124,7 @@ function invoice_admin_prepare_head($object)
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice_admin');
complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin');
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
@ -137,7 +136,7 @@ function invoice_admin_prepare_head($object)
$head[$h][2] = 'attributeslines';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice_admin','remove');
complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove');
return $head;
}

View File

@ -117,7 +117,7 @@ function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass)
/**
* Show a LDAP array into an HTML output array.
*
* @param string $result Array to show. This array is already encoded into charset_output
* @param array $result Array to show. This array is already encoded into charset_output
* @param int $level Level
* @param int $count Count
* @param string $var Var

View File

@ -116,10 +116,9 @@ function commande_prepare_head($object)
/**
* Return array head with list of tabs to view object informations.
*
* @param Object $object order
* @return array head array with tabs
* @return array head array with tabs
*/
function order_admin_prepare_head($object)
function order_admin_prepare_head()
{
global $langs, $conf, $user;
@ -131,7 +130,7 @@ function order_admin_prepare_head($object)
$head[$h][2] = 'general';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'order_admin');
complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
$head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
@ -143,7 +142,7 @@ function order_admin_prepare_head($object)
$head[$h][2] = 'attributeslines';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'order_admin','remove');
complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
return $head;
}

View File

@ -147,10 +147,9 @@ function product_prepare_head($object, $user)
/**
* Return array head with list of tabs to view object informations.
*
* @param Object $object Product
* @return array head array with tabs
*/
function product_admin_prepare_head($object=null)
function product_admin_prepare_head()
{
global $langs, $conf, $user;
@ -166,14 +165,14 @@ function product_admin_prepare_head($object=null)
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'product_admin');
complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin');
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'product_admin','remove');
complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin','remove');
return $head;
}

View File

@ -110,10 +110,9 @@ function propal_prepare_head($object)
/**
* Return array head with list of tabs to view object informations.
*
* @param Object $object Propal
* @return array head array with tabs
*/
function propal_admin_prepare_head($object)
function propal_admin_prepare_head()
{
global $langs, $conf, $user;
@ -129,7 +128,7 @@ function propal_admin_prepare_head($object)
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal_admin');
complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin');
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
@ -141,7 +140,7 @@ function propal_admin_prepare_head($object)
$head[$h][2] = 'attributeslines';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal_admin','remove');
complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove');
return $head;
}

View File

@ -242,9 +242,9 @@ function entity_prepare_head($object, $aEntities)
/**
* Show list of themes. Show all thumbs of themes
*
* @param User $fuser User concerned or null for global theme
* @param int $edit 1 to add edit form
* @param boolean $foruserprofile Show for user profile view
* @param User|null $fuser User concerned or null for global theme
* @param int $edit 1 to add edit form
* @param boolean $foruserprofile Show for user profile view
* @return void
*/
function show_theme($fuser,$edit=0,$foruserprofile=false)

View File

@ -51,7 +51,7 @@ class modPrintIPP extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Print via Cups IPP Printer.";
$this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 1;
@ -67,10 +67,11 @@ class modPrintIPP extends DolibarrModules
$this->config_page_url = array("printipp.php@printipp");
// Dependances
$this->hidden = (! empty($_SERVER["WINDIR"]));
$this->depends = array();
$this->requiredby = array();
$this->phpmin = array(5,1); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module
$this->phpmin = array(5,1); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module
$this->conflictwith = array();
$this->langfiles = array("printipp");

View File

@ -7,3 +7,8 @@ PRINTIPP_PORT=Port
PRINTIPP_USER=Login
PRINTIPP_PASSWORD=Password
NoPrinterFound=No printers found (check your CUPS setup)
FileWasSentToPrinter=File %s was sent to printer
NoDefaultPrinterDefined=No default printer defined
DefaultPrinter=Default printer
Printer=Printer
CupsServer=CUPS Server

View File

@ -35,6 +35,7 @@ if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha');
$value = GETPOST('value','alpha');
if (!$mode) $mode='config';
@ -68,6 +69,17 @@ if ($action == 'setvalue' && $user->admin)
}
}
// Set default model
else if ($action == 'setprinteruri')
{
if (dolibarr_set_const($db, "PRINTIPP_URI_DEFAULT",$value,'chaine',0,'',$conf->entity))
{
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf->global->PRINTIPP_URI_DEFAULT = $value;
}
}
/*
* View
@ -82,11 +94,6 @@ print_fiche_titre($langs->trans("PrintIPPSetup"),$linkback,'setup');
$head=printippadmin_prepare_head();
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"));
print $langs->trans("PrintIPPDesc")."<br>\n";
print '<br>';
if ($mode == 'config' && $user->admin)
{
@ -94,8 +101,11 @@ if ($mode == 'config' && $user->admin)
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">';
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
print '<table class="nobordernopadding" width="100%">';
print $langs->trans("PrintIPPDesc")."<br><br>\n";
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
@ -103,8 +113,9 @@ if ($mode == 'config' && $user->admin)
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
/*
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("PRINTIPP_ENABLED").'</td><td colspan="2" align="left">';
if (! empty($conf->use_javascript_ajax))
@ -123,7 +134,8 @@ if ($mode == 'config' && $user->admin)
}
}
print '</td></tr>';
*/
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print $langs->trans("PRINTIPP_HOST").'</td><td>';
@ -139,13 +151,13 @@ if ($mode == 'config' && $user->admin)
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("PRINTIPP_USER").'</td><td>';
print '<input size="32" type="text" name="PRINTIPP_USER" value="'.$conf->global->PRINTIPP_USER.'">';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("PRINTIPP_PASSWORD").'</td><td>';
print '<input size="32" type="text" name="PRINTIPP_PASSWORD" value="'.$conf->global->PRINTIPP_PASSWORD.'">';
print '</td></tr>';
@ -156,16 +168,22 @@ if ($mode == 'config' && $user->admin)
//print '<td>'.$langs->trans("Value").'</td>';
//print "</tr>\n";
print '<tr><td colspan="2" align="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></center>';
print '</form>';
}
if ($mode == 'test' && $user->admin)
{
print '<table class="nobordernopadding" width="100%">';
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
print $langs->trans("PrintIPPDesc")."<br><br>\n";
print '<table class="nobordernopadding" width="100%">';
$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 '<table width="100%" class="noborder">';
@ -180,6 +198,7 @@ if ($mode == 'test' && $user->admin)
//print '<td>Device</td>';
print '<td>Media</td>';
print '<td>Supported</td>';
print '<td>'.$langs->trans("Select").'</td>';
print "</tr>\n";
$list = $printer->getlist_available_printers();
@ -200,14 +219,26 @@ if ($mode == 'test' && $user->admin)
//print '<td>'.$printer_det->device_uri->_value0.'</td>';
print '<td>'.$printer_det->media_default->_value0.'</td>';
print '<td>'.$printer_det->media_type_supported->_value1.'</td>';
// Defaut
print "<td align=\"center\">";
if ($conf->global->PRINTIPP_URI_DEFAULT == "$value")
{
print img_picto($langs->trans("Default"),'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setprinteruri&mode=test&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
print '</td>';
print "</tr>\n";
}
print '</table>';
if (count($list) == 0) print $langs->trans("NoPrinterFound");
dol_fiche_end();
}
dol_fiche_end();
llxFooter();

View File

@ -36,12 +36,12 @@ function printippadmin_prepare_head()
$head = array();
$head[$h][0] = DOL_URL_ROOT."/printipp/admin/printipp.php?mode=config";
$head[$h][1] = $langs->trans("Config");
$head[$h][1] = $langs->trans("CupsServer");
$head[$h][2] = 'config';
$h++;
$head[$h][0] = DOL_URL_ROOT."/printipp/admin/printipp.php?mode=test";
$head[$h][1] = $langs->trans("Test");
$head[$h][1] = $langs->trans("Printer");
$head[$h][2] = 'test';
$h++;

View File

@ -68,7 +68,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("CompanySetup"),$linkback,'setup');
$head = societe_admin_prepare_head(null);
$head = societe_admin_prepare_head();
dol_fiche_head($head, 'attributes_contacts', $langs->trans("ThirdParties"), 0, 'company');