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;
$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;
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();
}
@$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();
}
'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',
'erfassen' => 'add',
'weiter' => 'continue',
'löschen' => 'delete',
+ 'ansprechpartner_löschen' => 'delete_contact',
'lieferadresse_löschen' => 'delete_shipto',
'neue_ware' => 'new_part',
'speichern' => 'save',
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',
-%]
</tr>
</table>
+ <input type="submit" id="delete_contact" name="action" value="Ansprechpartner löschen" disabled>
<br style="clear: left" />
</div>
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); }
</script>
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',
-%]
</tr>
</table>
+ <input type="submit" id="delete_contact" name="action" value="<translate>Delete Contact</translate>" disabled>
<br style="clear: left" />
</div>
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); }
</script>