diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index c784e9ae3b8..ee62b646604 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -126,6 +126,25 @@ if ($action == 'update' && !GETPOST('cancel')) { $action = 'edit'; } +if ($action == 'confirm_deleteproperty') { + $key = GETPOST('key', 'alpha'); + + //var_dump($currentConfigurations[$key]);exit; + if (isset($currentConfigurations[$key])) { + unset($currentConfigurations[$key]); + + $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE); + $res = dolibarr_set_const($db, 'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson, 'chaine', 0, '', $conf->entity); + if ($res) { + header("Location: ".$_SERVER['PHP_SELF']); + setEventMessages($langs->trans("SetupDeleted"), null, 'mesgs'); + exit; + } else { + setEventMessages($langs->trans("ErrorDeleting"), null, 'errors'); + } + } +} + /* * View @@ -152,11 +171,25 @@ $newbutton = ''; print load_fiche_titre($langs->trans("AIPromptForFeatures"), $newbutton, ''); +if ($action == 'deleteproperty') { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')), + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteSetup', GETPOST('key', 'alpha')), + 'confirm_deleteproperty', + '', + 0, + 1 + ); + print $formconfirm; +} + if ($action == 'edit') { $out .= '
'; $out .= ''; $out .= ''; + $out .= ''; $out .= ''; $out .= ''; @@ -235,7 +268,10 @@ if ($action == 'edit' || $action == 'create') { $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index ea68cd1810a..31859eb4ead 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -109,10 +109,10 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * Return an example of result returned by getNextValue * * @param Translate $langs Object langs - * @param Product $objproduct Object product + * @param ?Product $objproduct Object product * @return string Return string example */ - public function getExample($langs, $objproduct = 0) + public function getExample($langs, $objproduct = null) { $examplebarcode = $this->getNextValue($objproduct, ''); if (!$examplebarcode) { @@ -155,18 +155,19 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode return $out; } + /** * Return next value * - * @param CommonObject $objproduct Object product - * @param string $type Type of barcode (EAN, ISBN, ...) - * @return string Value if OK, '' if module not configured, <0 if KO + * @param ?CommonObject $objproduct Object product (not used) + * @param string $type Type of barcode (EAN, ISBN, ...) + * @return string Value if OK, '' if module not configured, <0 if KO */ - public function getNextValue($objproduct, $type = '') + public function getNextValue($objproduct = null, $type = '') { - global $db, $conf; + global $db; - if (!$objproduct instanceof Product) { + if (is_object($objproduct) && !$objproduct instanceof Product) { dol_syslog(get_class($this)."::getNextValue used on incompatible".get_class($objproduct), LOG_ERR); return -1; } @@ -178,13 +179,8 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode $type = getDolGlobalString('PRODUIT_DEFAULT_BARCODE_TYPE'); } //get barcode type configuration for products if $type not set - // TODO - // Get Mask value - $mask = ''; - if (getDolGlobalString('BARCODE_STANDARD_PRODUCT_MASK')) { - $mask = getDolGlobalString('BARCODE_STANDARD_PRODUCT_MASK'); - } + $mask = getDolGlobalString('BARCODE_STANDARD_PRODUCT_MASK'); if (empty($mask)) { $this->error = 'NotConfigured'; @@ -216,7 +212,8 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } } //End barcode with key - return $numFinal; + + return $numFinal; } diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php index a0e94fd69a1..0113e7dfb39 100644 --- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -72,10 +72,11 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ public function info($langs) { @@ -120,10 +121,10 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode * Return an example of result returned by getNextValue * * @param Translate $langs Object langs - * @param Societe $objthirdparty Object third-party + * @param ?Societe $objthirdparty Object third-party * @return string Return string example */ - public function getExample($langs, $objthirdparty = 0) + public function getExample($langs, $objthirdparty = null) { $examplebarcode = $this->getNextValue($objthirdparty, ''); if (!$examplebarcode) { @@ -169,13 +170,13 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode /** * Return next value * - * @param CommonObject $objthirdparty Object third-party + * @param ?CommonObject $objthirdparty Object third-party * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value if OK, '' if module not configured, <0 if KO */ - public function getNextValue($objthirdparty, $type = '') + public function getNextValue($objthirdparty = null, $type = '') { - global $db, $conf; + global $db; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // to be able to call function barcode_gen_ean_sum($ean) @@ -184,13 +185,8 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode $type = getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY'); } //get barcode type configuration for companies if $type not set - // TODO - // Get Mask value - $mask = ''; - if (getDolGlobalString('BARCODE_STANDARD_THIRDPARTY_MASK')) { - $mask = getDolGlobalString('BARCODE_STANDARD_THIRDPARTY_MASK'); - } + $mask = getDolGlobalString('BARCODE_STANDARD_THIRDPARTY_MASK'); if (empty($mask)) { $this->error = 'NotConfigured'; @@ -222,6 +218,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode } } //End barcode with key + return $numFinal; } @@ -242,10 +239,6 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode */ public function verif($db, &$code, $thirdparty, $thirdparty_type, $type) { - global $conf; - - //var_dump($code.' '.$thirdparty->ref.' '.$thirdparty_type);exit; - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $result = 0; @@ -273,6 +266,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode } dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result); + return $result; } diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index e037b9e0a09..7a283f5189f 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -62,11 +62,11 @@ abstract class ModeleNumRefBarCode extends CommonNumRefGenerator /** * Return next value available * - * @param CommonObject $objcommon Object Product, Thirdparty - * @param string $type Type of barcode (EAN, ISBN, ...) - * @return string Value + * @param ?CommonObject $objcommon Object Product, Thirdparty + * @param string $type Type of barcode (EAN, ISBN, ...) + * @return string Value */ - public function getNextValue($objcommon, $type = '') + public function getNextValue($objcommon = null, $type = '') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e632b93088a..576180c6371 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2425,6 +2425,7 @@ LargeModern=Large - Modern SpecialCharActivation=Enable the button to open a virtual keyboard to enter special characters DeleteExtrafield=Delete extrafield ConfirmDeleteExtrafield=Do you confirm deletion of the field %s ? All data saved into this field will be definitely deleted +ConfirmDeleteSetup=Are you sure you want to delete the setup for %s ? ExtraFieldsSupplierInvoicesRec=Complementary attributes (templates invoices) ExtraFieldsSupplierInvoicesLinesRec=Complementary attributes (template invoice lines) ParametersForTestEnvironment=Parameters for test environment
'.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']).''.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']); + $out .= ''.img_edit().''; + $out .= ''.img_delete().''; + $out .= '