$site_item_attribute_type_rs[] = $attribute_type_r; } db_free_result($results2); } $delete = TRUE; reset($site_item_attribute_type_rs); while (list(, $site_item_attribute_type_r) = each($site_item_attribute_type_rs)) { if (!is_s_item_attribute_type_deletable($v_s_item_type, $site_item_attribute_type_r['s_attribute_type'], $site_item_attribute_type_r['order_no'])) { $errors[] = array('error' => 'Dependent Item Attribute records exist', 'detail' => 's_item_type=' . $v_s_item_type . ', s_attribute_type=' . $site_item_attribute_type_r['s_attribute_type'] . ', order_no=' . $site_item_attribute_type_r['order_no']); $delete = FALSE; } } if ($delete) { reset($site_item_attribute_type_rs); while (list(, $site_item_attribute_type_r) = each($site_item_attribute_type_rs)) { if (!delete_s_item_attribute_type($v_s_item_type, $site_item_attribute_type_r['s_attribute_type'], $site_item_attribute_type_r['order_no'])) { $errors[] = array('error' => 'System Item Attribute Type (s_item_type=' . $v_s_item_type . ', s_attribute_type=' . $site_item_attribute_type_r['s_attribute_type'] . ', order_no=' . $site_item_attribute_type_r['order_no'] . ') not deleted', 'detail' => db_error()); } } } } else { if ($value == 'include') { for ($i = 0; $i < count($site_attribute_type_r); $i++) { if (!is_exists_item_attribute_type($v_s_item_type, $site_attribute_type_r[$i], 0)) { if (!insert_s_item_attribute_type($v_s_item_type, $site_attribute_type_r[$i], 0, NULL, 'N', 'N', 'N', 'N')) { $errors[] = array('error' => 'System Item Attribute Type (s_item_type=' . $v_s_item_type . ', s_attribute_type=' . $site_item_attribute_type_r['s_attribute_type'] . ', order_no=' . $site_attribute_type_r['order_no'] . ') not inserted', 'detail' => db_error()); } } } } }
if (is_not_empty_array($HTTP_VARS['s_attribute_type'])) { // Do delete operations here. for ($i = 0; $i < count($HTTP_VARS['s_attribute_type']); $i++) { //update or delete if ($HTTP_VARS['exists_ind'][$i] == 'Y') { // The 'old_order_no' will often be the same as 'order_no' but for instances where // they are different this test will match both! if (is_exists_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_attribute_type'][$i], $HTTP_VARS['old_order_no'][$i])) { if ($HTTP_VARS['order_no'][$i] != $HTTP_VARS['old_order_no'][$i]) { // If order_no has changed. if (is_s_item_attribute_type_deletable($HTTP_VARS['s_item_type'], $HTTP_VARS['s_attribute_type'][$i], $HTTP_VARS['old_order_no'][$i])) { if ($HTTP_VARS['order_no'][$i] != $HTTP_VARS['old_order_no'][$i]) { $HTTP_VARS['exists_ind'][$i] = 'N'; } // Delete old_order_no in both cases! if (!delete_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_attribute_type'][$i], $HTTP_VARS['old_order_no'][$i])) { $errors[] = array('error' => 'Item Attribute type (' . $HTTP_VARS['s_attribute_type'][$i] . '[' . $HTTP_VARS['old_order_no'][$i] . ']) not deleted', 'detail' => db_error()); } } else { $errors[] = array('error' => 'Item Attribute type (' . $HTTP_VARS['s_attribute_type'][$i] . '[' . $HTTP_VARS['old_order_no'][$i] . ']) not deleted', 'detail' => 'Dependant item attribute(s) with the same order_no exist.'); } } else { // 'old_order_no' IS THE SAME as 'order_no' here! // At the moment we are not checking the order_no's for items with the same type. if (!update_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_attribute_type'][$i], $HTTP_VARS['order_no'][$i], $HTTP_VARS['prompt'][$i], $HTTP_VARS['instance_attribute_ind'][$i], $HTTP_VARS['compulsory_ind'][$i], $HTTP_VARS['rss_ind'][$i], $HTTP_VARS['printable_ind'][$i])) { $errors[] = array('error' => 'Item Attribute type (' . $HTTP_VARS['s_attribute_type'][$i] . '[' . $HTTP_VARS['old_order_no'][$i] . ']) not updated', 'detail' => db_error()); } else { if ($HTTP_VARS['instance_attribute_ind'][$i] == "Y") { if (is_exists_non_instance_item_attributes($HTTP_VARS['s_item_type'], $HTTP_VARS['s_attribute_type'][$i], $HTTP_VARS['order_no'][$i])) { $errors[] = array('error' => 'Warning setting Instance Indicator to Y for item attribute relationship ' . $HTTP_VARS['s_attribute_type'][$i] . '[' . $HTTP_VARS['order_no'][$i] . ']', 'detail' => 'Item Attributes exist which are not linked to a item instance'); }