diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 36be4ee5a1d..10e796888b0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2898,9 +2898,9 @@ if ($action == 'create' && $usercancreate) { // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { - if (isModEnabled("supplier_order") && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if (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, ''); } } } 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'); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7ac90ace1b5..3b9285d7f22 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1951,7 +1951,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 43d9ce26c13..2a395c6a390 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1625,7 +1625,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)); @@ -1878,6 +1879,8 @@ if ($action == 'create') { print '