update scheme different obbligatorioweb
This commit is contained in:
@@ -170,10 +170,30 @@ try {
|
|||||||
|
|
||||||
$newDataType = $custom_field['Tipo'] ?? 'Testo';
|
$newDataType = $custom_field['Tipo'] ?? 'Testo';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Required logic:
|
||||||
|
* First read SchemiCustomFieldsDettagli.ObbligatorioWeb.
|
||||||
|
*
|
||||||
|
* Values:
|
||||||
|
* - "Si" => required for this schema
|
||||||
|
* - "No" => not required for this schema
|
||||||
|
* - "Predefinito" => use CustomField.ObbligatorioWeb
|
||||||
|
*/
|
||||||
|
$schemaRequired = trim((string)($field['ObbligatorioWeb'] ?? 'Predefinito'));
|
||||||
|
$customRequired = !empty($custom_field['ObbligatorioWeb']);
|
||||||
|
|
||||||
|
if (strcasecmp($schemaRequired, 'Si') === 0) {
|
||||||
|
$isRequired = 1;
|
||||||
|
} elseif (strcasecmp($schemaRequired, 'No') === 0) {
|
||||||
|
$isRequired = 0;
|
||||||
|
} else {
|
||||||
|
$isRequired = $customRequired ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
':schema_id' => $schema_id,
|
':schema_id' => $schema_id,
|
||||||
':data_type' => $newDataType,
|
':data_type' => $newDataType,
|
||||||
':is_required' => !empty($custom_field['ObbligatorioWeb']) ? 1 : 0,
|
':is_required' => $isRequired,
|
||||||
':default_value' => $custom_field['ValoreDefault'] ?? null,
|
':default_value' => $custom_field['ValoreDefault'] ?? null,
|
||||||
':has_list' => !empty($custom_field['Elenco']) ? 1 : 0,
|
':has_list' => !empty($custom_field['Elenco']) ? 1 : 0,
|
||||||
':length' => $custom_field['Lunghezza'] ?? 0,
|
':length' => $custom_field['Lunghezza'] ?? 0,
|
||||||
@@ -182,7 +202,7 @@ try {
|
|||||||
':max_value' => $custom_field['Massimo'] ?? null,
|
':max_value' => $custom_field['Massimo'] ?? null,
|
||||||
':default_curr_date' => !empty($custom_field['DefaultCurrDate']) ? 1 : 0,
|
':default_curr_date' => !empty($custom_field['DefaultCurrDate']) ? 1 : 0,
|
||||||
':tablename' => $target_table,
|
':tablename' => $target_table,
|
||||||
':field_label' => $custom_field['TitoloTraduzione'] ?? ''
|
':field_label' => $custom_field['TitoloTraduzione'] ?? $custom_field['Titolo'] ?? ''
|
||||||
];
|
];
|
||||||
|
|
||||||
$checkStmt->execute([$template_id, $fieldId]);
|
$checkStmt->execute([$template_id, $fieldId]);
|
||||||
@@ -234,7 +254,6 @@ try {
|
|||||||
|
|
||||||
$response["success"] = true;
|
$response["success"] = true;
|
||||||
$response["message"] = "Schema JSON updated, mappings synchronized, removed fields deleted, and changed fields updated successfully.";
|
$response["message"] = "Schema JSON updated, mappings synchronized, removed fields deleted, and changed fields updated successfully.";
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if (isset($pdo) && $pdo->inTransaction()) {
|
if (isset($pdo) && $pdo->inTransaction()) {
|
||||||
$pdo->rollback();
|
$pdo->rollback();
|
||||||
|
|||||||
Reference in New Issue
Block a user