Merge pull request #36442 from frederic34/patch-11
add modulepart for direct print capabilities
This commit is contained in:
commit
e4e5af0adf
11 changed files with 78 additions and 34 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2014-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2014-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -65,6 +65,7 @@ if ($action == 'print_file' && $user->hasRight('printing', 'read')) {
|
|||
|
||||
$subdir = '';
|
||||
$module = GETPOST('printer', 'alpha');
|
||||
// TODO make conversion in printing module
|
||||
switch ($module) {
|
||||
case 'livraison':
|
||||
$subdir = 'receipt';
|
||||
|
|
@ -74,7 +75,7 @@ if ($action == 'print_file' && $user->hasRight('printing', 'read')) {
|
|||
$subdir = 'sending';
|
||||
break;
|
||||
case 'commande_fournisseur':
|
||||
$module = 'fournisseur';
|
||||
$module = 'commande_fournisseur';
|
||||
$subdir = 'commande';
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -507,8 +507,32 @@ class FormFile
|
|||
}
|
||||
|
||||
$printer = 0;
|
||||
$supportedmoduleparts = [
|
||||
'company',
|
||||
'member',
|
||||
'product',
|
||||
'stock',
|
||||
'ficheinter',
|
||||
'user',
|
||||
'project',
|
||||
'contract',
|
||||
'facture',
|
||||
'supplier_proposal',
|
||||
'propal',
|
||||
'proposal',
|
||||
'order',
|
||||
'commande',
|
||||
'expedition',
|
||||
'commande_fournisseur',
|
||||
'facture_fournisseur',
|
||||
'expensereport',
|
||||
'delivery',
|
||||
'ticket',
|
||||
'bom',
|
||||
'mrp:mo',
|
||||
];
|
||||
// The direct print feature is implemented only for such elements
|
||||
if (in_array($modulepart, array('contract', 'facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) {
|
||||
if (in_array($modulepart, $supportedmoduleparts)) {
|
||||
$printer = ($user->hasRight('printing', 'read') && isModEnabled('printing'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (C) 2014-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2014-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -47,7 +47,6 @@ class PrintingDriver
|
|||
*/
|
||||
public $errors = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var string Name
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -244,7 +244,6 @@ class printing_printipp extends PrintingDriver
|
|||
*/
|
||||
public function getlistAvailablePrinters()
|
||||
{
|
||||
global $conf, $db;
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||
$ipp = new CupsPrintIPP();
|
||||
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log', 'file', 3); // logging very verbose
|
||||
|
|
@ -254,7 +253,12 @@ class printing_printipp extends PrintingDriver
|
|||
if (!empty($this->user)) {
|
||||
$ipp->setAuthentication($this->user, $this->password);
|
||||
}
|
||||
$ipp->getPrinters();
|
||||
try {
|
||||
$ipp->getPrinters();
|
||||
} catch (Exception $e) {
|
||||
setEventMessage($e->getMessage(), 'errors');
|
||||
}
|
||||
|
||||
return $ipp->available_printers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,14 +66,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
|||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('bills', 'companies', 'interventions', 'stocks'));
|
||||
|
||||
$id = GETPOSTINT('id');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$id = GETPOSTINT('id');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$ref_client = GETPOST('ref_client', 'alpha');
|
||||
$socid = GETPOSTINT('socid');
|
||||
$contratid = GETPOSTINT('contratid');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$mesg = GETPOST('msg', 'alpha');
|
||||
|
|
|
|||
|
|
@ -1342,6 +1342,9 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
// Actions when printing a doc from card
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
|
||||
// Actions to send emails
|
||||
$triggersendname = 'PRODUCT_SENTBYMAIL';
|
||||
$paramname = 'id';
|
||||
|
|
|
|||
|
|
@ -284,6 +284,8 @@ if (empty($reshook)) {
|
|||
$action = '';
|
||||
}
|
||||
|
||||
// Actions when printing a doc from card
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->stock->dir_output;
|
||||
|
|
|
|||
|
|
@ -614,6 +614,9 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
// Actions when printing a doc from card
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
|
||||
// Actions to send emails
|
||||
$triggersendname = 'PROJECT_SENTBYMAIL';
|
||||
$paramname = 'id';
|
||||
|
|
|
|||
|
|
@ -945,6 +945,9 @@ if (empty($reshook)) {
|
|||
$upload_dir = !empty($conf->societe->multidir_output[$object->entity ?? $conf->entity]) ? $conf->societe->multidir_output[$object->entity ?? $conf->entity] : $conf->societe->dir_output;
|
||||
$permissiontoadd = $user->hasRight('societe', 'creer');
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
// Actions when printing a doc from card
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1094,12 +1097,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
}
|
||||
}
|
||||
|
||||
$object->phone = GETPOST('phone', 'alpha');
|
||||
$object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
|
||||
$object->fax = GETPOST('fax', 'alpha');
|
||||
$object->email = GETPOST('email', 'email');
|
||||
$object->url = GETPOST('url', 'url');
|
||||
$object->capital = GETPOST('capital'); // can be null or 0 or a float value
|
||||
$object->phone = GETPOST('phone', 'alpha');
|
||||
$object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
|
||||
$object->fax = GETPOST('fax', 'alpha');
|
||||
$object->email = GETPOST('email', 'email');
|
||||
$object->url = GETPOST('url', 'url');
|
||||
$object->capital = GETPOST('capital'); // can be null or 0 or a float value
|
||||
$paymentTermId = GETPOSTINT('cond_reglement_id'); // can be set by default values on create page and not already in get or post variables
|
||||
if (empty($paymentTermId) && !GETPOSTISSET('cond_reglement_id')) {
|
||||
$paymentTermId = getDolGlobalString('MAIN_DEFAULT_PAYMENT_TERM_ID');
|
||||
|
|
@ -1109,28 +1112,28 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
if (empty($paymentTypeId) && !GETPOSTISSET('mode_reglement_id')) {
|
||||
$paymentTypeId = getDolGlobalString('MAIN_DEFAULT_PAYMENT_TYPE_ID');
|
||||
}
|
||||
$object->mode_reglement_id = $paymentTypeId;
|
||||
$object->barcode = GETPOST('barcode', 'alphanohtml');
|
||||
$object->idprof1 = GETPOST('idprof1', 'alphanohtml');
|
||||
$object->idprof2 = GETPOST('idprof2', 'alphanohtml');
|
||||
$object->idprof3 = GETPOST('idprof3', 'alphanohtml');
|
||||
$object->idprof4 = GETPOST('idprof4', 'alphanohtml');
|
||||
$object->idprof5 = GETPOST('idprof5', 'alphanohtml');
|
||||
$object->idprof6 = GETPOST('idprof6', 'alphanohtml');
|
||||
$object->mode_reglement_id = $paymentTypeId;
|
||||
$object->barcode = GETPOST('barcode', 'alphanohtml');
|
||||
$object->idprof1 = GETPOST('idprof1', 'alphanohtml');
|
||||
$object->idprof2 = GETPOST('idprof2', 'alphanohtml');
|
||||
$object->idprof3 = GETPOST('idprof3', 'alphanohtml');
|
||||
$object->idprof4 = GETPOST('idprof4', 'alphanohtml');
|
||||
$object->idprof5 = GETPOST('idprof5', 'alphanohtml');
|
||||
$object->idprof6 = GETPOST('idprof6', 'alphanohtml');
|
||||
$object->typent_id = GETPOSTINT('typent_id');
|
||||
$object->effectif_id = GETPOSTINT('effectif_id');
|
||||
$object->civility_id = GETPOST('civility_id', 'alpha');
|
||||
$object->effectif_id = GETPOSTINT('effectif_id');
|
||||
$object->civility_id = GETPOST('civility_id', 'alpha');
|
||||
|
||||
$object->tva_assuj = GETPOSTINT('assujtva_value');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->status = GETPOSTINT('status');
|
||||
|
||||
//Local Taxes
|
||||
$object->localtax1_assuj = GETPOSTINT('localtax1assuj_value');
|
||||
$object->localtax2_assuj = GETPOSTINT('localtax2assuj_value');
|
||||
$object->localtax1_assuj = GETPOSTINT('localtax1assuj_value');
|
||||
$object->localtax2_assuj = GETPOSTINT('localtax2assuj_value');
|
||||
|
||||
$object->localtax1_value = GETPOST('lt1', 'alpha');
|
||||
$object->localtax2_value = GETPOST('lt2', 'alpha');
|
||||
$object->localtax1_value = GETPOST('lt1', 'alpha');
|
||||
$object->localtax2_value = GETPOST('lt2', 'alpha');
|
||||
|
||||
$object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
|
||||
|
||||
|
|
@ -1147,7 +1150,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
}
|
||||
}
|
||||
if (GETPOSTISSET('accountancy_code_buy')) {
|
||||
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
|
||||
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
|
||||
|
||||
if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') {
|
||||
$object->accountancy_code_buy = '';
|
||||
|
|
@ -1159,7 +1162,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
$object->logo = (isset($_FILES['photo']) ? dol_sanitizeFileName($_FILES['photo']['name']) : '');
|
||||
|
||||
// Company logo management
|
||||
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos";
|
||||
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos";
|
||||
$file_OK = (isset($_FILES['photo']) ? is_uploaded_file($_FILES['photo']['tmp_name']) : false);
|
||||
if ($file_OK) {
|
||||
if (image_format_supported($_FILES['photo']['name'])) {
|
||||
|
|
|
|||
|
|
@ -688,6 +688,8 @@ if (empty($reshook)) {
|
|||
$action = 'view';
|
||||
}
|
||||
|
||||
// Actions when printing a doc from card
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
|
||||
$permissiondellink = $user->hasRight('ticket', 'write');
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once'
|
||||
|
|
|
|||
|
|
@ -879,6 +879,9 @@ if (empty($reshook)) {
|
|||
// Actions to build doc
|
||||
$upload_dir = $conf->user->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
// Actions when printing a doc from card
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue