From 6c1536aad4882e22fe0be62f295749d436e0f49d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 19 Feb 2008 15:59:08 +0000 Subject: [PATCH] Contacts loeschbar gemacht (gibt noch kleinere probleme mit dem javascript) --- SL/CT.pm | 25 +++++++++++++++++++ bin/mozilla/ct.pl | 18 +++++++++++-- locale/de/all | 1 + locale/de/ct | 1 + templates/webpages/ct/form_header_de.html | 6 +++-- templates/webpages/ct/form_header_master.html | 6 +++-- 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index 6cd9b91db..96b6b9cb3 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -827,6 +827,14 @@ sub get_contact { map { $form->{$_} = $ref->{$_} } keys %$ref; + $query = qq|SELECT COUNT(cp_id) AS used FROM ( + SELECT cp_id FROM oe UNION + SELECT cp_id FROM ar UNION + SELECT cp_id FROM ap UNION + SELECT cp_id FROM delivery_orders + ) AS cpid WHERE cp_id = ? OR ? = 0|; + ($form->{cp_used}) = selectfirst_array_query($form, $dbh, $query, ($form->{cp_id})x2); + $sth->finish; $dbh->disconnect; @@ -1003,4 +1011,21 @@ sub delete_shipto { $main::lxdebug->leave_sub(); } +sub delete_shipto { + $main::lxdebug->enter_sub(); + + my $self = shift; + my $shipto_id = shift; + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $dbh = $form->get_standard_dbh(\%myconfig); + + do_query($form, $dbh, qq|UPDATE contacts SET cp_cv_id = NULL WHERE cp_id = ?|, $shipto_id); + + $dbh->commit(); + + $main::lxdebug->leave_sub(); +} + 1; diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index f72362e03..2a6aaca2b 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -565,7 +565,7 @@ sub get_contact { CT->get_contact(\%myconfig, \%$form); print $cgi->header(), join '__pjx__', map $form->{"cp_$_"}, - qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday); + qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used); $lxdebug->leave_sub(); } @@ -603,7 +603,21 @@ sub delete_shipto { @$form{ grep /^shipto/, keys %$form } = undef; - display(); + edit(); + + $main::lxdebug->leave_sub(); +} + +sub delete_contact { + $main::lxdebug->enter_sub(); + + $auth->assert('customer_vendor_edit'); + + CT->delete_shipto($form->{cp_id}); + + @$form{ grep /^cp_/, keys %$form } = undef; + + edit(); $main::lxdebug->leave_sub(); } diff --git a/locale/de/all b/locale/de/all index 4835f1103..a7b2ff520 100644 --- a/locale/de/all +++ b/locale/de/all @@ -437,6 +437,7 @@ aktualisieren wollen?', 'Defaults saved.' => 'Die Standardeinstellungen wurden gespeichert.', 'Delete' => 'Löschen', 'Delete Account' => 'Konto löschen', + 'Delete Contact' => 'Ansprechpartner löschen', 'Delete Dataset' => 'Datenbank löschen', 'Delete Shipto' => 'Lieferadresse löschen', 'Delete delivery order' => 'Lieferschein löschen', diff --git a/locale/de/ct b/locale/de/ct index a2d15c631..79a9caafc 100644 --- a/locale/de/ct +++ b/locale/de/ct @@ -236,6 +236,7 @@ $self->{subs} = { 'erfassen' => 'add', 'weiter' => 'continue', 'löschen' => 'delete', + 'ansprechpartner_löschen' => 'delete_contact', 'lieferadresse_löschen' => 'delete_shipto', 'neue_ware' => 'new_part', 'speichern' => 'save', diff --git a/templates/webpages/ct/form_header_de.html b/templates/webpages/ct/form_header_de.html index 77a226a57..6a3749edc 100644 --- a/templates/webpages/ct/form_header_de.html +++ b/templates/webpages/ct/form_header_de.html @@ -316,7 +316,7 @@ name = 'cp_id', id = 'cp_id', DATA = CONTACTS, - onChange = "get_contact(['cp_id__' + this.value], ['cp_name', 'cp_greeting', 'cp_title', 'cp_givenname', 'cp_phone1', 'cp_phone2', 'cp_email', 'cp_abteilung', 'cp_fax', 'cp_mobile1', 'cp_mobile2', 'cp_satphone', 'cp_satfax', 'cp_project', 'cp_privatphone', 'cp_privatemail', 'cp_birthday'])", + onChange = "get_contact(['cp_id__'+this.value],['cp_name','cp_greeting','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2','cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact])", id_key = 'cp_id', label_sub = 'contacts_label', -%] @@ -445,6 +445,7 @@ +
@@ -595,5 +596,6 @@ Calendar.setup({ inputField : "FU_date", ifFormat :"[% myconfig_jsc_dateformat %]", align : "BR", button : "FU_date_trigger" }); //--> - function enable_delete_shipto(used){ var s=document.getElementById('delete_shipto'); if (s) s.disabled = (used > 0 ? true : false); } + function enable_delete_shipto(used) { var s=document.getElementById('delete_shipto'); if (s) s.disabled = (used > 0 ? true : false); } + function enable_delete_contact(used){ var s=document.getElementById('delete_contact'); if (s) s.disabled = (used > 0 ? true : false); } diff --git a/templates/webpages/ct/form_header_master.html b/templates/webpages/ct/form_header_master.html index 0dadc080f..0ab1afffd 100644 --- a/templates/webpages/ct/form_header_master.html +++ b/templates/webpages/ct/form_header_master.html @@ -316,7 +316,7 @@ name = 'cp_id', id = 'cp_id', DATA = CONTACTS, - onChange = "get_contact(['cp_id__' + this.value], ['cp_name', 'cp_greeting', 'cp_title', 'cp_givenname', 'cp_phone1', 'cp_phone2', 'cp_email', 'cp_abteilung', 'cp_fax', 'cp_mobile1', 'cp_mobile2', 'cp_satphone', 'cp_satfax', 'cp_project', 'cp_privatphone', 'cp_privatemail', 'cp_birthday'])", + onChange = "get_contact(['cp_id__'+this.value],['cp_name','cp_greeting','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2','cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact])", id_key = 'cp_id', label_sub = 'contacts_label', -%] @@ -445,6 +445,7 @@ +
@@ -595,5 +596,6 @@ Calendar.setup({ inputField : "FU_date", ifFormat :"[% myconfig_jsc_dateformat %]", align : "BR", button : "FU_date_trigger" }); //--> - function enable_delete_shipto(used){ var s=document.getElementById('delete_shipto'); if (s) s.disabled = (used > 0 ? true : false); } + function enable_delete_shipto(used) { var s=document.getElementById('delete_shipto'); if (s) s.disabled = (used > 0 ? true : false); } + function enable_delete_contact(used){ var s=document.getElementById('delete_contact'); if (s) s.disabled = (used > 0 ? true : false); } -- 2.20.1