X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fcontacts_view.inc;h=07e3066deff1224036ee083cf95d2501ebcb09bb;hb=6ffe5f040543994725beaf9f8059c054919043d7;hp=9ad82aec4c0224e5f9bacde9522b7f4ec7fc0fd3;hpb=320f9583fa487bd0e14fbfe779e2ecc00b4d909f;p=fa-stable.git diff --git a/includes/ui/contacts_view.inc b/includes/ui/contacts_view.inc index 9ad82aec..07e3066d 100644 --- a/includes/ui/contacts_view.inc +++ b/includes/ui/contacts_view.inc @@ -45,26 +45,37 @@ class contacts extends simple_crud { table_header($th); $k = 0; - while ($myrow = db_fetch($contacts)) - { - alt_table_row_color($k); - label_cell($myrow["description"]); - label_cell($myrow["ref"]); - label_cell($myrow["name"].' '.$myrow["name2"]); - label_cell($myrow["phone"]); - label_cell($myrow["phone2"]); - label_cell($myrow["fax"]); - email_cell($myrow["email"]); + $last = $myrow = db_fetch($contacts); + while ($last) + { + + if ($myrow['id'] != $last['id']) { + alt_table_row_color($k); + label_cell(implode('
',$description)); + label_cell($last["ref"]); + label_cell($last["name"].' '.$last["name2"]); + label_cell($last["phone"]); + label_cell($last["phone2"]); + label_cell($last["fax"]); + email_cell($last["email"]); // inactive_control_cell($myrow["id"], $myrow["inactive"], 'crm_contacts', 'id'); - edit_button_cell("{$this->name}Edit[{$myrow['id']}]", _("Edit")); + edit_button_cell("{$this->name}Edit[{$last['id']}]", _("Edit")); // delete button removes only category unless this is the last contact for this person - delete_button_cell("{$this->name}Delete[{$myrow['contact_id']}]", _("Delete")); - end_row(); + delete_button_cell("{$this->name}Delete[{$last['id']}]", _("Delete")); + end_row(); + $description = array(); + $last = $myrow; + } + + if ($myrow) { + $description[] = $myrow['description']; + $myrow = db_fetch($contacts); + } } - + //inactive_control_row($th); end_table(1); } @@ -73,7 +84,7 @@ class contacts extends simple_crud { { br(); - start_outer_table(TABLESTYLE, "width=80%"); + start_outer_table(TABLESTYLE); table_section(1); table_section_title(_("Contact data")); @@ -94,6 +105,7 @@ class contacts extends simple_crud { email_row(_("E-mail:"), 'email', @$this->data['email'], 35, 55); table_section(2); + table_section_title(" "); textarea_row(_("Address:"), 'address', @$this->data['address'], 30, 4); languages_list_row( _("Document Language:"), 'lang', @$this->data['lang'], _("Customer default")); @@ -142,15 +154,14 @@ class contacts extends simple_crud { return true; } // - // Delete single contact only (unless this is last contact for this person) + // Delete all contacts for person in current class/entity // function db_delete() { - $rel = get_crm_contact($this->selected_id); - if (delete_crm_contact($this->selected_id)) { + if (delete_crm_contacts($this->selected_id, $this->class, $this->entity)) { // if this is the last relation - delete contact data - $rels = get_person_contacts($rel['person_id']); + $rels = get_person_contacts($this->selected_id); if (count($rels)==0) { - return delete_crm_person($rel['person_id']); + return delete_crm_person($this->selected_id); } } return false;