diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 29ed90bb7be..fdbb86d1a62 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -210,7 +210,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -272,7 +272,7 @@ if ($action == 'create') { // Edit mode if ($action == 'update') { - dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); + print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); print ''."\n"; print ''; @@ -327,7 +327,7 @@ if ($action == 'create') { // View mode $linkback = ''.$langs->trans("BackToList").''; - dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); + print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref'); diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index f68fbc18905..db17be68e1e 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -102,7 +102,7 @@ print ''."\n"; print ''; print ''; -dol_fiche_head(); +print dol_get_fiche_head(); print '
'; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index a4227a761a4..97b92bdd172 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -159,7 +159,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print '
'; @@ -202,7 +202,7 @@ if ($action == 'create') $head = fiscalyear_prepare_head($object); if ($action == 'edit') { - dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print dol_get_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); print ''."\n"; print ''; @@ -257,7 +257,7 @@ if ($action == 'create') print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); } - dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print dol_get_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); print '
'; diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index f293c9b450b..2971e2eb114 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -49,7 +49,7 @@ if ($id) { $head = fiscalyear_prepare_head($object); - dol_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron'); + print dol_get_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron'); print '
'; dol_print_object_info($object); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 8ca880de25f..6a9fdcbffff 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -351,7 +351,7 @@ if ($action == 'create') print ''."\n"; print ''."\n"; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -415,7 +415,7 @@ if ($action == 'create') $head[$h][2] = 'transaction'; $h++; - dol_fiche_head($head, 'transaction', '', -1); + print dol_get_fiche_head($head, 'transaction', '', -1); //dol_banner_tab($object, '', $backlink); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 321ef282dff..9e21a712e7e 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -135,7 +135,7 @@ $head = societe_prepare_head($object); dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); -dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company'); +print dol_get_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index 144c2595d25..a0f930e50d7 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -134,7 +134,7 @@ $head = societe_prepare_head($object); dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); -dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company'); +print dol_get_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index ed8f347a177..4343946a85e 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -119,7 +119,7 @@ if (!empty($id)) { print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_accountancy'); - dol_fiche_head(); + print dol_get_fiche_head(); print '
'; diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index ab02592f6b8..153717d05e4 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -121,7 +121,7 @@ if (!empty($id)) { print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_accountancy'); - dol_fiche_head(); + print dol_get_fiche_head(); print '
'; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 4a4747cfaf4..bee34f291f5 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -121,7 +121,7 @@ if (!empty($id)) { print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_accountancy'); - dol_fiche_head(); + print dol_get_fiche_head(); print '
'; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index a7e7a6f3634..c0b5998f035 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -118,7 +118,7 @@ if ($object->id > 0) { if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); - dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index cd432aa12d6..128b915ef0f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos García - * Copyright (C) 2012-2018 Philippe Grand + * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * @@ -833,7 +833,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; if ($backtopage) print ''; - dol_fiche_head(''); + print dol_get_fiche_head(''); print '
'; print ''; @@ -1058,7 +1058,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; if ($backtopage) print ''; - dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); + print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); print '
'; @@ -1268,7 +1268,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { */ $head = member_prepare_head($object); - dol_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); // Confirm create user if ($action == 'create_user') { diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 32630b9e478..0f6e6250796 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -100,7 +100,7 @@ if ($id > 0) { $head = member_prepare_head($object); - dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a09844da014..78c5a263ce1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1634,6 +1634,7 @@ class Propal extends CommonObject $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; + $sql .= " fk_input_reason=".(isset($this->demand_reason_id) ? $this->demand_reason_id : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 0ab4974ce7f..85ad01ab7a6 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -981,6 +981,45 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } + /** + * Get discount from invoice + * + * @param int $id Id of invoice + * + * @url GET {id}/discount + * + * @return mixed + */ + public function getDiscount($id) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + if (!DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } + + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } + + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $discountcheck = new DiscountAbsolute($this->db); + $result = $discountcheck->fetch(0, $this->invoice->id); + + if ($result == 0){ + throw new RestException(404, 'Discount not found'); + } + if ($result < 0){ + throw new RestException(500, $discountcheck->error); + } + + return parent::_cleanObjectDatas($discountcheck); + } + /** * Create a discount (credit available) for a credit note or a deposit. * diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 4f795274ad2..ba902c4b773 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -206,10 +206,10 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>200), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>210), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>220), // Not enabled by default because slow - 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled)?0:1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled)?0:1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || empty($conf->global->DISPLAY_MARGIN_RATES)?0:1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || empty($conf->global->DISPLAY_MARK_RATES)?0:1)), + 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous?0:1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous?0:1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES)?0:1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES)?0:1)), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 249d2dd9b8c..76c6833c07b 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -81,7 +81,7 @@ if ($id > 0 || !empty($ref)) $totalpaye = $object->getSommePaiement(); - dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'); + print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'); // Invoice content diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 0591d75d5a3..cdf5a0e62c4 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -8,6 +8,7 @@ * Copyright (C) 2016 Marcos García * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2020 Josep Lluís Amador * * 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 @@ -143,8 +144,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= ", s.nom as name"; $sql .= ", s.rowid as socid, s.email"; $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').")"; @@ -161,6 +163,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; $sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; // Add Group from hooks $parameters = array(); @@ -207,6 +210,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; $companystatic->client = 1; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index de672af203b..72c5bf3e825 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * 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 @@ -385,7 +385,7 @@ if ($action == 'new') $sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, "; $sql .= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,"; - $sql .= " p.rowid as paymentid"; + $sql .= " p.rowid as paymentid, p.ref as paymentref"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)"; @@ -411,6 +411,7 @@ if ($action == 'new') $lines[$obj->bid][$i]["banque"] = $obj->banque; $lines[$obj->bid][$i]["id"] = $obj->transactionid; $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid; + $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref; $i++; } @@ -482,7 +483,7 @@ if ($action == 'new') // Link to payment print '
'; $paymentstatic->id = $value["paymentid"]; - $paymentstatic->ref = $value["paymentid"]; + $paymentstatic->ref = $value["paymentref"]; if ($paymentstatic->id) { print $paymentstatic->getNomUrl(1); @@ -616,7 +617,7 @@ if ($action == 'new') // List of bank checks $sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,"; $sql .= " b.dateo as date, b.datec as datec, b.banque,"; - $sql .= " p.rowid as pid, ba.rowid as bid, p.statut"; + $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; @@ -662,9 +663,8 @@ if ($action == 'new') // Link to payment print ''; $paymentstatic->id = $objp->pid; - $paymentstatic->ref = $objp->pid; - if ($paymentstatic->id) - { + $paymentstatic->ref = $objp->pref; + if ($paymentstatic->id) { print $paymentstatic->getNomUrl(1); } else { print ' '; @@ -673,8 +673,7 @@ if ($action == 'new') // Link to bank transaction print ''; $accountlinestatic->rowid = $objp->rowid; - if ($accountlinestatic->rowid) - { + if ($accountlinestatic->rowid) { print $accountlinestatic->getNomUrl(1); } else { print ' '; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 1710b4dda6a..45fd513d1a3 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * 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 @@ -66,9 +66,9 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- if ($file_OK) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; if (GETPOST('deletephoto')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo; $dirthumbs = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/thumbs'; dol_delete_file($fileimg); @@ -134,7 +134,7 @@ if ($action == 'edit') * Fiche en mode edition */ - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 219d35e46fb..45f0fb8613e 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -75,6 +75,9 @@ if ($action == 'add' && !empty($permissiontoadd)) $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { $value = ((GETPOST($key) == '1' || GETPOST($key) == 'on') ? 1 : 0); + } elseif ($object->fields[$key]['type'] == 'reference') { + $tmparraykey = array_keys($object->param_list); + $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2'); } else { $value = GETPOST($key, 'alphanohtml'); } @@ -162,6 +165,8 @@ if ($action == 'update' && !empty($permissiontoadd)) $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0); + } elseif ($object->fields[$key]['type'] == 'reference') { + $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2'); } else { $value = GETPOST($key, 'alpha'); } diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index e88fc937e38..3137c93a9c5 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -33,18 +33,24 @@ if ($action == 'print_file' && $user->rights->printing->read) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; $objectprint = new PrintingDriver($db); $list = $objectprint->listDrivers($db, 10); + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); if (!empty($list)) { $errorprint = 0; $printerfound = 0; foreach ($list as $driver) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; - $langs->load($driver); + foreach ($dirmodels as $dir) { + if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) { + $classfile = dol_buildpath($dir, 0).$driver.'.modules.php'; + break; + } + } + require_once $classfile; $classname = 'printing_'.$driver; $printer = new $classname($db); + $langs->load($printer::LANGFILE); //print '
'.print_r($printer, true).'
'; - if (!empty($conf->global->{$printer->active})) - { + if (!empty($conf->global->{$printer->active})) { $printerfound++; $subdir = ''; diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index f87fbd7b282..5a1ef8df7b9 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -125,7 +125,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->type = $objp->type; $contractlinestatic->product_id = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; - $contratlignestatic->product_type = $objp->product_type; + $contractlinestatic->product_type = $objp->product_type; $contractlinestatic->statut = $objp->contractline_status; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 6cab6580a5a..ba636ac2569 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -815,7 +815,7 @@ class dolReceiptPrinter extends Printer } } // If is DummyPrintConnector send to log to debugging - if ($this->printer->connector instanceof DummyPrintConnector) + if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $data = $this->printer->connector->getData(); if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo base64_encode($data); @@ -868,6 +868,11 @@ class dolReceiptPrinter extends Printer public function initPrinter($printerid) { global $conf; + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ + $this->connector = new DummyPrintConnector(); + $this->printer = new Printer($this->connector, $this->profile); + return; + } $error = 0; $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 00f1f537ac2..54cd54dccbe 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4390,7 +4390,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', // Right print '
'; - print ''; + print ''; if ($sortfield) $options .= "&sortfield=".urlencode($sortfield); if ($sortorder) $options .= "&sortorder=".urlencode($sortorder); // Show navigation bar diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4156b89a2ab..0ff40659daa 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1278,6 +1278,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description short of product line $libelleproduitservice = $label; + if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) { + $libelleproduitservice = '' . $libelleproduitservice . ''; + } // Description long of product line if (!empty($desc) && ($desc != $label)) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 2af8fcc9bfb..a75d437ab21 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1656,7 +1656,7 @@ class pdf_crabe extends ModelePDFFactures if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir"); if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit"); if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma"); - if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation"); + if ($this->situationinvoice) $title = $outputlangs->transnoentities("PDFInvoiceSituation"); $pdf->MultiCell($w, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 7e730fabbc5..61e5007e6c8 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1899,11 +1899,11 @@ class pdf_sponge extends ModelePDFFactures if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir"); if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit"); if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma"); - if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation"); + if ($this->situationinvoice) $title = $outputlangs->transnoentities("PDFInvoiceSituation"); if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { $title .= ' - '; if ($object->type == 0) { - if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("InvoiceSituation"); + if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("PDFInvoiceSituation"); $title .= $outputlangsbis->transnoentities("PdfInvoiceTitle"); } elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities("InvoiceReplacement"); elseif ($object->type == 2) $title .= $outputlangsbis->transnoentities("InvoiceAvoir"); diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index 186caca619a..6f8dfe92073 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2019 Frédéric France + * Copyright (C) 2020 Josep Lluís Amador * * 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 @@ -68,7 +69,7 @@ class mod_mo_advanced extends ModeleNumRefMos $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index e7e16dc7979..a368a7265df 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -66,12 +66,17 @@ class PrintingDriver $type = 'printing'; $list = array(); - $moduledir = DOL_DOCUMENT_ROOT."/core/modules/printing/"; - $tmpfiles = dol_dir_list($moduledir, 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0); - foreach ($tmpfiles as $record) { + $listoffiles = array(); + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); + foreach ($dirmodels as $dir) { + $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0); + if (!empty($tmpfiles)) { + $listoffiles = array_merge($listoffiles, $tmpfiles); + } + } + foreach ($listoffiles as $record) { $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']); - } - + } return $list; } diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index e1f765110a8..096c633036a 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -35,16 +35,39 @@ use OAuth\OAuth2\Service\Google; */ class printing_printgcp extends PrintingDriver { + /** + * @var string module name + */ public $name = 'printgcp'; + + /** + * @var string module description + */ public $desc = 'PrintGCPDesc'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'printer'; + + /** + * @var string module description + */ public $active = 'PRINTING_PRINTGCP'; + + /** + * @var array module parameters + */ public $conf = array(); + + /** + * @var string google id + */ public $google_id = ''; + + /** + * @var string google secret + */ public $google_secret = ''; /** @@ -68,6 +91,7 @@ class printing_printgcp extends PrintingDriver const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/search'; const PRINTERS_GET_JOBS = 'https://www.google.com/cloudprint/jobs'; const PRINT_URL = 'https://www.google.com/cloudprint/submit'; + const LANGFILE = 'printgcp'; /** * Constructor @@ -280,7 +304,7 @@ class printing_printgcp extends PrintingDriver $responsedata = json_decode($response, true); $printers = $responsedata['printers']; // Check if we have printers? - if (count($printers) == 0) { + if (is_array($printers) && count($printers) == 0) { // We dont have printers so return blank array $ret['available'] = array(); } else { diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 6b0e528aa1e..873382ceae2 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -30,19 +30,54 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; */ class printing_printipp extends PrintingDriver { + /** + * @var string module name + */ public $name = 'printipp'; + + /** + * @var string module description + */ public $desc = 'PrintIPPDesc'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'printer'; + + /** + * @var string Constant name + */ public $active = 'PRINTING_PRINTIPP'; + + /** + * @var array array of setup value + */ public $conf = array(); + + /** + * @var string host + */ public $host; + + /** + * @var string port + */ public $port; - public $userid; /* user login */ + + /** + * @var string username + */ + public $userid; + + /** + * @var string login for printer host + */ public $user; + + /** + * @var string password for printer host + */ public $password; /** @@ -60,6 +95,8 @@ class printing_printipp extends PrintingDriver */ public $db; + const LANGFILE = 'printipp'; + /** * Constructor @@ -113,7 +150,7 @@ class printing_printipp extends PrintingDriver $obj = $this->db->fetch_object($result); if ($obj) { - dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id); + dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id); $ipp->setPrinterURI($obj->printer_id); } else { if (!empty($conf->global->PRINTIPP_URI_DEFAULT)) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 9c918bd0a15..7336f2b1e57 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -531,6 +531,7 @@ TypeContact_invoice_supplier_external_SERVICE=Vendor service contact InvoiceFirstSituationAsk=First situation invoice InvoiceFirstSituationDesc=The situation invoices are tied to situations related to a progression, for example the progression of a construction. Each situation is tied to an invoice. InvoiceSituation=Situation invoice +PDFInvoiceSituation=Situation invoice InvoiceSituationAsk=Invoice following the situation InvoiceSituationDesc=Create a new situation following an already existing one SituationAmount=Situation invoice amount(net) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 46943c6c9ab..8922bc00eb5 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -90,6 +90,8 @@ class modMyModule extends DolibarrModules 'barcode' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 'models' => 0, + // Set this to 1 if module has its own printing directory (core/modules/printing) + 'printing' => 0, // Set this to 1 if module has its own theme directory (theme) 'theme' => 0, // Set this to relative path of css file if module has its own css file diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 2f906c68382..b810be417ae 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -69,8 +69,7 @@ if ($action == 'setconst' && $user->admin) if (!$result > 0) $error++; } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null); } else { @@ -87,8 +86,7 @@ if ($action == 'setvalue' && $user->admin) $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); if (!$result > 0) $error++; - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null); } else { @@ -131,10 +129,17 @@ if ($mode == 'setup' && $user->admin) $submit_enabled = 0; if (!empty($driver)) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); + foreach ($dirmodels as $dir) { + if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) { + $classfile = dol_buildpath($dir, 0).$driver.'.modules.php'; + break; + } + } + require_once $classfile; $classname = 'printing_'.$driver; - $langs->load($driver); $printer = new $classname($db); + $langs->load($printer::LANGFILE); $i = 0; $submit_enabled = 0; @@ -246,22 +251,27 @@ if ($mode == 'config' && $user->admin) $object = new PrintingDriver($db); $result = $object->listDrivers($db, 10); + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); foreach ($result as $driver) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + foreach ($dirmodels as $dir) { + if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) { + $classfile = dol_buildpath($dir, 0).$driver.'.modules.php'; + break; + } + } + require_once $classfile; $classname = 'printing_'.$driver; - $langs->load($driver); $printer = new $classname($db); + $langs->load($printer::LANGFILE); //print '
'.print_r($printer, true).'
'; print ''; print ''; print '
'.img_picto('', $printer->picto).' '.$langs->trans($printer->desc).''; - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff($printer->active); } else { - if (empty($conf->global->{$printer->conf})) - { + if (empty($conf->global->{$printer->conf})) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; @@ -284,12 +294,19 @@ if ($mode == 'test' && $user->admin) print $langs->trans('PrintTestDesc'.$driver)."

\n"; print ''; - if (!empty($driver)) - { - require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + if (!empty($driver)) { + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); + foreach ($dirmodels as $dir) { + if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) { + $classfile = dol_buildpath($dir, 0).$driver.'.modules.php'; + break; + } + } + require_once $classfile; $classname = 'printing_'.$driver; $langs->load($driver); $printer = new $classname($db); + $langs->load($printer::LANGFILE); //print '
'.print_r($printer, true).'
'; if (count($printer->getlistAvailablePrinters())) { if ($printer->listAvailablePrinters() == 0) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2aa9b3330e3..2427ac74714 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2627,7 +2627,7 @@ class Product extends CommonObject } $sql .= " WHERE c.rowid = cd.fk_commande"; $sql .= " AND c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'commande').")"; $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -2727,7 +2727,7 @@ class Product extends CommonObject } $sql .= " WHERE c.rowid = cd.fk_commande"; $sql .= " AND c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND c.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")"; $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -2786,7 +2786,7 @@ class Product extends CommonObject $sql .= " WHERE e.rowid = ed.fk_expedition"; $sql .= " AND c.rowid = cd.fk_commande"; $sql .= " AND e.fk_soc = s.rowid"; - $sql .= " AND e.entity IN (".getEntity('expedition').")"; + $sql .= " AND e.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'expedition').")"; $sql .= " AND ed.fk_origin_line = cd.rowid"; $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { @@ -2863,7 +2863,7 @@ class Product extends CommonObject } $sql .= " WHERE cf.rowid = fd.fk_commande"; $sql .= " AND cf.fk_soc = s.rowid"; - $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND cf.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")"; $sql .= " AND fd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } @@ -2914,7 +2914,7 @@ class Product extends CommonObject $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE m.rowid = mp.fk_mo"; - $sql .= " AND m.entity IN (".getEntity('mrp').")"; + $sql .= " AND m.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mrp').")"; $sql .= " AND mp.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 2518f0ee17d..a5fd94236ad 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -366,7 +366,7 @@ if ($usevirtualstock) if (!empty($conf->commande->enabled)) { $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd1, ".MAIN_DB_PREFIX."commande as c1"; - $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity('commande').")"; + $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'commande').")"; $sqlCommandesCli .= " AND cd1.fk_product = p.rowid"; $sqlCommandesCli .= " AND c1.fk_statut IN (1,2))"; } else { @@ -379,7 +379,7 @@ if ($usevirtualstock) $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."expeditiondet as ed2,"; $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commande as c2,"; $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commandedet as cd2"; - $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity('expedition').")"; + $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'expedition').")"; $sqlExpeditionsCli .= " AND cd2.fk_commande = c2.rowid"; $sqlExpeditionsCli .= " AND c2.fk_statut IN (1,2)"; $sqlExpeditionsCli .= " AND cd2.fk_product = p.rowid"; @@ -393,14 +393,14 @@ if ($usevirtualstock) $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; $sqlCommandesFourn .= " WHERE c3.rowid = cd3.fk_commande"; - $sqlCommandesFourn .= " AND c3.entity IN (".getEntity('supplier_order').")"; + $sqlCommandesFourn .= " AND c3.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")"; $sqlCommandesFourn .= " AND cd3.fk_product = p.rowid"; $sqlCommandesFourn .= " AND c3.fk_statut IN (3,4))"; $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf4,"; $sqlReceptionFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd4"; - $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity('supplier_order').")"; + $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")"; $sqlReceptionFourn .= " AND fd4.fk_product = p.rowid"; $sqlReceptionFourn .= " AND cf4.fk_statut IN (3,4))"; } else { @@ -412,7 +412,7 @@ if ($usevirtualstock) $sqlProductionToConsume = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlProductionToConsume .= " FROM ".MAIN_DB_PREFIX."mrp_mo as mm5,"; $sqlProductionToConsume .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; - $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity('mo').")"; + $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo').")"; $sqlProductionToConsume .= " AND mp5.fk_product = p.rowid"; $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consummed')"; $sqlProductionToConsume .= " AND mm5.status IN (1,2))"; @@ -420,7 +420,7 @@ if ($usevirtualstock) $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlProductionToProduce .= " FROM ".MAIN_DB_PREFIX."mrp_mo as mm5,"; $sqlProductionToProduce .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; - $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity('mo').")"; + $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo').")"; $sqlProductionToProduce .= " AND mp5.fk_product = p.rowid"; $sqlProductionToProduce .= " AND mp5.role IN ('toproduce', 'produced')"; $sqlProductionToProduce .= " AND mm5.status IN (1,2))"; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index b1cd367f258..4007851ccb2 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -610,6 +610,10 @@ if (!empty($type)) if ($type == 'f') $label = 'NewSupplier'; } +if ($contextpage = 'poslist' && ( !empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { + print get_htmloutput_mesg(img_warning('default') . ' ' . $langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); +} + // Show the new button only when this page is not opend from the Extended POS (pop-up window) // but allow it too, when a user has the rights to create a new customer if ($contextpage != 'poslist') diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 108fdea0b64..d87e15d9ffe 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -221,32 +221,34 @@ if (!empty($conf->stock->enabled)) } } -if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { +if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { // Select printer to use with terminal require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; $printer = new dolReceiptPrinter($db); - $printer->listprinters(); - $printers = array(); - foreach ($printer->listprinters as $key => $value) { - $printers[$value['rowid']] = $value['name']; - } - print ''; - print ''; - if ($conf->global->TAKEPOS_ORDER_PRINTERS) { - print ''; + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { + $printer->listprinters(); + $printers = array(); + foreach ($printer->listprinters as $key => $value) { + $printers[$value['rowid']] = $value['name']; + } + print ''; print ''; - print ''; - print ''; - print ''; - print ''; + if ($conf->global->TAKEPOS_ORDER_PRINTERS) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } } $printer->listPrintersTemplates(); $templates = array(); diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 531598668a7..1d49f985578 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -144,7 +144,7 @@ if ($action == 'getProducts') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $printer = new dolReceiptPrinter($db); // check printer for terminal - if ($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term} > 0 && $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term} > 0) { + if (($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term} > 0 || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term} > 0) { $object = new Facture($db); $object->fetch($id); $ret = $printer->sendToPrinter($object, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term}); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index fc0fd749242..3a67c81d4ba 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1110,7 +1110,7 @@ if ($placeid > 0) $moreinfo .= '
'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); $moreinfo .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; - + if ($line->date_start || $line->date_end) $htmlforlines .= '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; $htmlforlines .= ''; $htmlforlines .= ''; $htmlforlines .= '
'.$langs->trans("MainPrinterToUse").''; - print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1); - print '
'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1
'.$langs->trans("MainPrinterToUse").''; - print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}), 1); - print '
'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2'; - print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}), 1); - print '
'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3'; - print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}), 1); + print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1); print '
'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1'; + print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}), 1); + print '
'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2'; + print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}), 1); + print '
'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3'; + print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}), 1); + print '
'.vatrate($line->remise_percent, true).'';