diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 52fc3fa27d9..8c204e99039 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2014-2024 Frédéric France + * Copyright (C) 2014-2025 Frédéric France * Copyright (C) 2024 MDW * * 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; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6ab8eaca887..92f10d73c0c 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -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')); } diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index e1df70fa5f7..d9aabb51d9a 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -1,6 +1,6 @@ + * Copyright (C) 2014-2025 Frédéric France * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -47,7 +47,6 @@ class PrintingDriver */ public $errors = array(); - /** * @var string Name */ diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index f51d105f650..17f57351398 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -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; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 089374b8b6e..280329b3f0b 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -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'); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 05868f72fb0..a46d4ca06b9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -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'; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 6d37679a266..363f39b3968 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -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; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index e97160987bf..b53a8ee9954 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -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'; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b9ca8e591da..7d1ff903a2f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -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'])) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 4b9c98d7bf0..cf4c724e88f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -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' diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 241f56d47ef..a3c307bc880 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -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'; }