From 8518aa5d384134c9f86071fa91736de2cf12bad6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2023 19:05:35 +0200 Subject: [PATCH 1/6] Fix link to create event, bad date --- htdocs/societe/agenda.php | 2 +- htdocs/societe/messaging.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index e2887ebf284..7c790c11bf3 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -168,7 +168,7 @@ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); } $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); - $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel'); } $morehtmlright = ''; diff --git a/htdocs/societe/messaging.php b/htdocs/societe/messaging.php index de8c7396c3a..4fdc1c54a69 100644 --- a/htdocs/societe/messaging.php +++ b/htdocs/societe/messaging.php @@ -158,7 +158,7 @@ if ($socid > 0) { $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); } $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); - $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel'); } $morehtmlright = ''; From ca2f07fe67ece9166006602b2f15d8559e681aaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2023 12:16:27 +0200 Subject: [PATCH 2/6] Clean the notification popup code --- htdocs/core/js/lib_notification.js.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index 94fc9904a61..168bd23eb7b 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -80,7 +80,9 @@ if ("Notification" in window) { /* Check if permission ok */ if (Notification.permission !== "granted") { console.log("Ask Notification.permission"); - Notification.requestPermission(); + Notification.requestPermission(function(result) { + console.log("result for requestPermission is "+result); + }); } /* Launch timer */ @@ -96,7 +98,7 @@ if ("Notification" in window) { console.log("This browser in this context does not support Notification."); } - +/* The method called after time_first_execution on each page */ function first_execution() { console.log("Call first_execution of check_events()"); result = check_events(); //one check before setting the new time for other checks @@ -106,6 +108,7 @@ function first_execution() { } } +/* the method call frequently every time_auto_update */ function check_events() { var result = 0; dolnotif_nb_test_for_page += 1; @@ -124,7 +127,7 @@ function check_events() { console.log("Call ajax to check events with time_js_next_test = "+time_js_next_test+" dolnotif_nb_test_for_page="+dolnotif_nb_test_for_page); $.ajax("", { - type: "post", // Usually post or get + type: "POST", // Usually post or get async: true, data: { time_js_next_test: time_js_next_test, forcechecknow: 1, token: currentToken, dolnotif_nb_test_for_page: dolnotif_nb_test_for_page }, dataType: "json", @@ -147,6 +150,8 @@ function check_events() { var url = "notdefined"; var title = "Not defined"; var body = value.label; + var icon = ''; + var image = ''; if (value.type == 'agenda' && value.location != null && value.location != '') { body += '\n' + value.location; } @@ -161,15 +166,17 @@ function check_events() { title = 'transnoentities('EventReminder')) ?>'; } var extra = { - icon: '', - //image: '', + icon: icon, body: body, + lang: 'getDefaultLang(1)); ?>', tag: value.id_agenda, requireInteraction: true + /* only supported for persistent notification shown using ServiceWorkerRegistration.showNotification() so disabled */ + /* actions: [{ action: 'action1', title: 'New Button Label' }, { action: 'action2', title: 'Another Button' }] */ }; // We release the notify - console.log("Send notification on browser"); + console.log("Send notification on browser url="+url); noti[index] = new Notification(title, extra); if (index==0 && audio) { @@ -178,7 +185,8 @@ function check_events() { if (noti[index]) { noti[index].onclick = function (event) { - console.log("A click on notification on browser has been done"); + /* If the use has clicked on button Activate */ + console.log("A click on notification on browser has been done for url="+url); event.preventDefault(); // prevent the browser from focusing the Notification's tab window.focus(); window.open(url, '_blank'); From 3d6538f2a3e9079ccedfead18e168953287beb70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2023 17:29:24 +0200 Subject: [PATCH 3/6] Fix search on all on product list --- htdocs/product/list.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index fbd9bcf5907..6c54127f4e7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -182,7 +182,7 @@ $fieldstosearchall = array( 'p.label'=>"ProductLabel", 'p.description'=>"Description", "p.note"=>"Note", - + 'pfp.ref_fourn'=>'RefSupplier' ); // multilang if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -192,6 +192,7 @@ if (getDolGlobalInt('MAIN_MULTILANGS')) { } if (isModEnabled('barcode')) { $fieldstosearchall['p.barcode'] = 'Gencod'; + $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice'; } // Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel;p.description=Description;p.note=Note;' if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) { @@ -447,7 +448,7 @@ $sqlfields = $sql; // $sql fields to remove for count total $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (isModEnabled('workstation')) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "workstation_workstation ws ON (p.fk_default_workstation = ws.rowid)"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "workstation_workstation as ws ON (p.fk_default_workstation = ws.rowid)"; } if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); @@ -471,8 +472,13 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) { + // Clean $fieldstosearchall + $newfieldstosearchall = $fieldstosearchall; + unset($newfieldstosearchall['pfp.ref_fourn']); + unset($newfieldstosearchall['pfp.barcode']); + $sql .= ' AND ('; - $sql .= natural_search(array_keys($fieldstosearchall), $sall, 0, 1); + $sql .= natural_search(array_keys($newfieldstosearchall), $sall, 0, 1); // Search also into a supplier reference 'pfp.ref_fourn'="RefSupplier" $sql .= ' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid'; $sql .= ' AND ('.natural_search('pfp.ref_fourn', $sall, 0, 1); @@ -626,6 +632,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); $sqlforcount = preg_replace('/'.preg_quote($linktopfp, '/').'/', '', $sqlforcount); $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); if ($resql) { $objforcount = $db->fetch_object($resql); From 39dd7021454ce320e6115e328adf6771e63882db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2023 17:59:46 +0200 Subject: [PATCH 4/6] Fix warning in option WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER --- htdocs/commande/card.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0a458b7b103..ea047c9a82f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2847,7 +2847,7 @@ if ($action == 'create' && $usercancreate) { // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut > Commande::STATUS_DRAFT && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 46122f6ff69..7848b2c43d0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1878,7 +1878,7 @@ class CommandeFournisseur extends CommonOrder // Predefine quantity according to packaging if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $prod = new Product($this->db); - $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); + $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', (empty($this->fk_soc) ? $this->socid : $this->fk_soc)); if ($qty < $prod->packaging) { $qty = $prod->packaging; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 247a3633b14..252faba5954 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1620,7 +1620,8 @@ if ($action == 'create') { $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - $soc = $objectsrc->client; + $soc = $objectsrc->thirdparty; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); @@ -1867,6 +1868,8 @@ if ($action == 'create') { print '
'; print ''; + $selectedLines = array(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; From 101ddf2a759eb8d0fa55001082dad3392392a0fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2023 18:05:57 +0200 Subject: [PATCH 5/6] FIX link to create purchase order from sale order --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ea047c9a82f..332b0d8acb9 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2849,7 +2849,7 @@ if ($action == 'create' && $usercancreate) { if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut > Commande::STATUS_DRAFT && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { - print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); + print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id, ''); } } } From 336927ad704a78d80e698b007975264dd3fa0fcf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2023 17:59:46 +0200 Subject: [PATCH 6/6] Fix link to create puchase order from sale order --- htdocs/commande/card.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 94ba56db84d..0b681b65160 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2735,7 +2735,7 @@ if ($action == 'create' && $usercancreate) { if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { - print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); + print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id, ''); } } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7efcb5bf9a8..c7ab4b57303 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1874,7 +1874,7 @@ class CommandeFournisseur extends CommonOrder // Predefine quantity according to packaging if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $prod = new Product($this->db); - $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); + $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', (empty($this->fk_soc) ? $this->socid : $this->fk_soc)); if ($qty < $prod->packaging) { $qty = $prod->packaging; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8f5a4a7ac33..86c2087b783 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1599,7 +1599,8 @@ if ($action == 'create') { $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - $soc = $objectsrc->client; + $soc = $objectsrc->thirdparty; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); @@ -1846,6 +1847,8 @@ if ($action == 'create') { print '
'; print ''; + $selectedLines = array(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
';