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 '
'; print ''; + $selectedLines = array(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 9c9f3e5f274..0f99d58720e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -189,7 +189,7 @@ $fieldstosearchall = array( 'p.label'=>"ProductLabel", 'p.description'=>"Description", "p.note"=>"Note", - + 'pfp.ref_fourn'=>'RefSupplier' ); // multilang if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -199,6 +199,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)) { @@ -467,7 +468,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); @@ -490,8 +491,13 @@ if (getDolGlobalString('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); @@ -648,6 +654,7 @@ if (!getDolGlobalInt('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);