X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=admin%2Fcrm_categories.php;h=f043443af4e680f70cc2c13b16fab6654c9a5071;hb=fc24ee893402902fc58632dabb5d7c2594e191d0;hp=bf24403ea3e96774f2f49a24120ceb84a4a909d4;hpb=46c5f7a65a7659a44ae8254c63152074363d3987;p=fa-stable.git diff --git a/admin/crm_categories.php b/admin/crm_categories.php index bf24403e..f043443a 100644 --- a/admin/crm_categories.php +++ b/admin/crm_categories.php @@ -52,11 +52,20 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') } } +function key_in_crm_contacts($id) // extra function for testing foreign concatenated key. Joe 02.09.2013. +{ + $row = get_crm_category($id); + $sql = "SELECT COUNT(*) FROM ".TB_PREF."crm_contacts WHERE type='".$row['type']."' AND action='".$row['action']."'"; + $result = db_query($sql, "check relations for crm_contacts failed"); + $contacts = db_fetch($result); + return $contacts[0]; +} + if ($Mode == 'Delete') { $cancel_delete = 0; - if (key_in_foreign_table($selected_id, 'crm_relations', 'category_id')) + if (key_in_crm_contacts($selected_id)) { $cancel_delete = 1; display_error(_("Cannot delete this category because there are contacts related to it.")); @@ -83,9 +92,9 @@ if ($Mode == 'RESET') $result = get_crm_categories(check_value('show_inactive')); start_form(); -start_table(TABLESTYLE, "width=50%"); +start_table(TABLESTYLE, "width='70%'"); -$th = array(_("Type id"), _("Action id"), _("Short Name"), _("Description"), "", " "); +$th = array(_("Category Type"), _("Category Subtype"), _("Short Name"), _("Description"), "", " "); inactive_control_column($th); table_header($th); @@ -101,7 +110,7 @@ while ($myrow = db_fetch($result)) label_cell($myrow["name"]); label_cell($myrow["description"]); - inactive_control_cell($myrow["id"], $myrow["inactive"], 'areas', 'id'); + inactive_control_cell($myrow["id"], $myrow["inactive"], 'crm_categories', 'id'); edit_button_cell("Edit".$myrow["id"], _("Edit")); if ($myrow["system"])