X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=144d5405c2efa5757fb1488715ff25e1954ab04d;hb=98912ac0e8ca237cb9ce5a969f026a099b2954ea;hp=260d77e6c50ab702deee3a2ccad2a31d8f186956;hpb=09655ec6f1761d464a928f6aab88bb936999df25;p=freeside.git
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 260d77e6c..c36a6e4b7 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -1,460 +1,400 @@
-<%
-#
-
-use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum
- $last $first $ss $company $address1 $address2 $city $zip
- $daytime $night $fax @invoicing_list $invoicing_list $payinfo
- $payname %payby %paybychecked $refnum $otaker $r );
-use vars qw ( $conf $saved_pkgpart $username $password $popnum $ulen $ulen2 );
-use vars qw ( $error );
-#use CGI::Switch;
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup getotaker);
-#use FS::Record qw(qsearch qsearchs fields);
-use FS::Record qw(qsearch qsearchs fields dbdef);
-use FS::CGI qw(header popurl itable table);
-use FS::cust_main;
-use FS::agent;
-use FS::part_referral;
-use FS::cust_main_county;
-
- #for misplaced logic below
- use FS::part_pkg;
-
- #for false laziness below (now more properly lazy)
- use FS::svc_acct_pop;
-
- #for (other) false laziness below
- use FS::agent;
- use FS::type_pkgs;
-
-$conf = new FS::Conf;
-
-#get record
-
-$error = '';
-if ( $cgi->param('error') ) {
- $error = $cgi->param('error');
- $cust_main = new FS::cust_main ( {
- map { $_, scalar($cgi->param($_)) } fields('cust_main')
- } );
- $custnum = $cust_main->custnum;
- $saved_pkgpart = $cgi->param('pkgpart_svcpart') || '';
- if ( $saved_pkgpart =~ /^(\d+)_/ ) {
- $saved_pkgpart = $1;
- } else {
- $saved_pkgpart = '';
+<& /elements/header.html,
+ $title,
+ '',
+ ' onUnload="myclose()"' #hmm, in billing.html
+&>
+
+<& /elements/error.html &>
+
+
${r}Contact name (last, first) |
-END
-
-print < ,
-
-END
-
-print <SS# | |
-Company | |
-${r}Address | |
- | |
-${r}City | | ${r}State/Country | | ${r}Zip | | !;
-
-($daytime,$night,$fax)=(
- $cust_main->daytime,
- $cust_main->night,
- $cust_main->fax,
-);
-
-print <Day Phone | |
-Night Phone | |
-Fax | |
-END
+#get record
-print "$r required fields ";
+my($custnum, $cust_main, $ss, $stateid, $payinfo, @invoicing_list);
+my $pkgpart_svcpart = ''; #first_pkg
+my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct
+my %svc_phone = ();
+my %svc_dsl = ();
+my $prospectnum = '';
+my $locationnum = '';
+my $same = '';
-# service address
+$m->comp('/elements/handle_uri_query', 'secure'=>1);
-if ( defined $cust_main->dbdef_table->column('ship_last') ) {
+if ( $cgi->param('error') ) {
- print "\n", <
- function changed(what) {
- what.form.same.checked = false;
- }
- function samechanged(what) {
- if ( what.checked ) {
-END
-print " what.form.ship_$_.value = what.form.$_.value;\n"
- for (qw( last first company address1 address2 city zip daytime night fax ));
-print <param('same') || '') eq 'Y';
+ # false laziness w/ edit/process/cust_main.cgi
+ my %locations;
+ for my $pre (qw(bill ship)) {
+ my %hash;
+ foreach ( FS::cust_main->location_fields ) {
+ $hash{$_} = scalar($cgi->param($pre.'_'.$_));
}
+ $hash{'custnum'} = $cgi->param('custnum');
+ $locations{$pre} = qsearchs('cust_location', \%hash)
+ || FS::cust_location->new( \%hash );
}
-
-END
-
- print ' Service address ',
- '(ship_last ) {
- print ' CHECKED';
- foreach (
- qw( last first company address1 address2 city state zip daytime night fax)
- ) {
- $cust_main->set("ship_$_", $cust_main->get($_) );
- }
+ if ( $same ) {
+ $locations{ship} = $locations{bill};
}
- print '>same as billing address) ';
-
- my($ship_last,$ship_first,$ship_company,$ship_address1,$ship_address2,$ship_city,$ship_zip)=(
- $cust_main->ship_last,
- $cust_main->ship_first,
- $cust_main->ship_company,
- $cust_main->ship_address1,
- $cust_main->ship_address2,
- $cust_main->ship_city,
- $cust_main->ship_zip,
- );
-
- print &itable("#cccccc"), <${r}Contact name (last, first) |
-END
-
- print < ,
-
-END
-
- print <
- Company | |
- ${r}Address | |
- | |
- ${r}City | | ${r}State/Country | | ${r}Zip | | !;
- my($ship_daytime,$ship_night,$ship_fax)=(
- $cust_main->ship_daytime,
- $cust_main->ship_night,
- $cust_main->ship_fax,
- );
+ $custnum = $cust_main->custnum;
- print <Day Phone | |
- Night Phone | |
- Fax | |
-END
+ die "access denied"
+ unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
- print "$r required fields ";
+ @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
+ $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
+ $ss = $cust_main->ss; # don't mask an entered value on errors
+ $stateid = $cust_main->stateid; # don't mask an entered value on errors
+ $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
-}
+ $cust_main->national_id( $cgi->param('national_id1') || $cgi->param('national_id2') );
-# billing info
-
-sub expselect {
- my $prefix = shift;
- my( $m, $y ) = (0, 0);
- if ( scalar(@_) ) {
- my $date = shift || '01-2000';
- if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
- ( $m, $y ) = ( $2, $1 );
- } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
- ( $m, $y ) = ( $1, $3 );
- } else {
- die "unrecognized expiration date format: $date";
- }
- }
+ $prospectnum = $cgi->param('prospectnum') || '';
- my $return = qq! | |