From b31455ec31222bd0e882b76895baa794d80acb17 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sun, 13 May 2012 16:21:27 -0700 Subject: [PATCH] add cust_main-custom_content config item for Globelink's custom customer view, RT#17579 --- FS/FS/Conf.pm | 7 ++++ FS/FS/cust_pkg.pm | 2 +- httemplate/view/cust_main.cgi | 9 ++++- .../cust_main/custom_content/.birthdate.html.swp | Bin 0 -> 12288 bytes .../custom_content/.small_custview.html.swp | Bin 0 -> 12288 bytes .../custom_content/.spouse_birthdate.html.swp | Bin 0 -> 12288 bytes .../cust_main/custom_content/.svc_Common.html.swp | Bin 0 -> 12288 bytes .../cust_main/custom_content/.svc_acct.html.swp | Bin 0 -> 12288 bytes .../custom_content/.svc_hardware.html.swp | Bin 0 -> 12288 bytes .../cust_main/custom_content/.svc_phone.html.swp | Bin 0 -> 12288 bytes .../view/cust_main/custom_content/birthdate.html | 15 ++++++++ .../cust_main/custom_content/small_custview.html | 8 +++++ .../cust_main/custom_content/spouse_birthdate.html | 15 ++++++++ .../view/cust_main/custom_content/svc_Common.html | 40 +++++++++++++++++++++ .../view/cust_main/custom_content/svc_acct.html | 7 ++++ .../cust_main/custom_content/svc_hardware.html | 7 ++++ .../view/cust_main/custom_content/svc_phone.html | 7 ++++ 17 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 httemplate/view/cust_main/custom_content/.birthdate.html.swp create mode 100644 httemplate/view/cust_main/custom_content/.small_custview.html.swp create mode 100644 httemplate/view/cust_main/custom_content/.spouse_birthdate.html.swp create mode 100644 httemplate/view/cust_main/custom_content/.svc_Common.html.swp create mode 100644 httemplate/view/cust_main/custom_content/.svc_acct.html.swp create mode 100644 httemplate/view/cust_main/custom_content/.svc_hardware.html.swp create mode 100644 httemplate/view/cust_main/custom_content/.svc_phone.html.swp create mode 100644 httemplate/view/cust_main/custom_content/birthdate.html create mode 100644 httemplate/view/cust_main/custom_content/small_custview.html create mode 100644 httemplate/view/cust_main/custom_content/spouse_birthdate.html create mode 100644 httemplate/view/cust_main/custom_content/svc_Common.html create mode 100644 httemplate/view/cust_main/custom_content/svc_acct.html create mode 100644 httemplate/view/cust_main/custom_content/svc_hardware.html create mode 100644 httemplate/view/cust_main/custom_content/svc_phone.html diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index a1fda682f..da8717e25 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -4784,6 +4784,13 @@ and customer address. Include units.', }, { + 'key' => 'cust_main-custom_content', + 'section' => 'UI', + 'description' => 'As an alternative to cust_main-custom_link (leave it blank), the contant to display on this customer page, one item per line. Available iems are: small_custview, birthdate, spouse_birthdate, svc_acct, svc_phone and svc_external.', + 'type' => 'textarea', + }, + + { 'key' => 'cust_main-custom_title', 'section' => 'UI', 'description' => 'Title for the "Custom" tab in the View Customer page.', diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 1d4a90c56..788b1d363 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -2070,7 +2070,7 @@ sub cust_svc { } if ( $opt{'svcdb'} ) { $search{addl_from} = ' LEFT JOIN part_svc USING ( svcpart ) '; - $search{hashref}->{svcdb} = $opt{'svcdb'}; + $search{extra_sql} = ' AND svcdb = '. dbh->quote( $opt{'svcdb'} ); } cluck "cust_pkg->cust_svc called" if $DEBUG > 2; diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 9ce55b0b9..83f28d395 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -277,7 +277,13 @@ function areyousure(href, message) { % } % if ( $view eq 'custom' ) { +% if ( $conf->config('cust_main-custom_link') ) { <& cust_main/custom.html, $cust_main &> +% } elsif ( $conf->config('cust_main-custom_content') ) { + <& cust_main/custom_content.html, $cust_main &> +% #} else { +% # warn "custom view without cust_main-custom_link or -custom_content?"; +% } % } @@ -326,7 +332,8 @@ $views{emt('Payment History')} = 'payment_history' $views{emt('Change History')} = 'change_history' if $curuser->access_right('View customer history'); $views{$conf->config('cust_main-custom_title') || emt('Custom')} = 'custom' - if $conf->config('cust_main-custom_link'); + if $conf->config('cust_main-custom_link') + || $conf->config('cust_main-custom_content'); $views{emt('Jumbo')} = 'jumbo'; my %viewname = reverse %views; diff --git a/httemplate/view/cust_main/custom_content/.birthdate.html.swp b/httemplate/view/cust_main/custom_content/.birthdate.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..9571d22cf9f3025787bdba9b063a6986319723ab GIT binary patch literal 12288 zcmeI2-D(p-6vwB6;7zUA7dURSoeg9=)m|w1*ft+3g-9TYqE}&)ooyEOBW%V-rRYQW z0>uXq-$n2Z6v0~`z%%Q%StJ^~RL;PE&&-@NXJ&qL6>`S=PmUkK-Ms^b?FM6??tSQ; zizD{s8e_q!8|&$H%@3tiGk38r?zK)R{8Y+$;7Ku6N=CELRZ^S=av>(q=V}zWL7erH zXf#P;C1WMVL8_)6#_dg26t3Ha{6v5VtR}F@4({CE*S;O&7Hr>qygH0#i2xBG0z`la z5CI}U1c(3;_%8{l*#>)qH@lMGZY#GNzu0_8h6oS=B0vO)01+SpM1Tko0U|&IhyW4z z2MM?yV{bPZ`-am0|6lz6|BRh?sHdnt>KN5TRZ!cgkJlM{kCG@0brtnJ&+`@Sxz0z8 z2oM1xKm>>Y5g-CYfCvx)B0vO|1nR;JP};Jap5<#eP`WGz zx1G!K?+S}vLdjFmSnY>cBC(%AxXH**(#X}(RtZbVecRFB;Kbs(mOS_JGMt@(VMfCA zg!#-U*Ru6G5*NmD0S^Y%Y8!{zfr&1P)XV5T8r4`mf490AHe22M4#Q4gKVyB^f!4!z zuiNW4j2%B~hEq4Q8yxDd?aWo`Yid@haHKNmhX>QaOr0##E(jUQ2y5ZzLZ!Cy?9d&{ wFe`_z0M7=RIYi3hnlB_iv~<-xUT+tVlpPJ)-R5A>F#LHC$1)u!FARtM0PoY+!vFvP literal 0 HcmV?d00001 diff --git a/httemplate/view/cust_main/custom_content/.small_custview.html.swp b/httemplate/view/cust_main/custom_content/.small_custview.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..a39f52ddeb800513096fce668113282c78892687 GIT binary patch literal 12288 zcmeI&!AiqG5C-6>h-6JlXrtaRbt-i-x3MviFZ+Fs zfwQLSQK&-z0y6?j-PZnI(=Tsstc$hP?#vD>KmY;|fB*y_009U<00RG4z-2YM=GU7m zUva+7wQsqcB0&HG5P$##AOHafKmY;|fB*y_@COCrKG9^E=#j(!|DS&Uzw-Qr3h`C3 nXGmO>^bNewY|5 zjlEHtD3K_hPts{FykVHBaRBb?V--hdy$sip01}uJm@4VqTPB-#Zg1$xRqGaAx%qs) zjusL?0!RP}AOR$R1dsp{Kmz|g0X117Zz0P|MW)w_e(6+S46#E3NB{{S0VIF~kN^@u z0!RP}AOR$R1TG)}KOp3InUJp_{r~^T@BbfQyazo4JqEQvHINOu3i^DFkdL6JpcT+h z*#EtV^9}lUpgquC5H=)$1dsp{Kmter2_OL^fCP}hg(cA7c9?|9C3N2YHdmvJ)fb)S z?u%BXa5;w%McDI;w0O?B%~Ti*?@gKrMw>2^QR=HOIbhWy6XUr}J5a1W08hu28Ps!& zNje&rDKkAYK24XF{?vUt?&(VJDv4jyQlMz_pKde}K>D{Yywa0t7W;Zrxdb)j(sA`O zJSa0=JzlJ`3OzcamK}3D;Py+aQaAgxCu~f_j6UqwYHb+m1qgIfonC?E9j{Ir#T{ty z!EUSjz$IYp>nqV1bZF~QyVvdQH?37^n&mcZlgPGyLZT{@nqj%LaHI;=7lzs{MCzDG zYm|#f#83pEbCo$Na3X&wB2xfgrOXWU7of2!v%V>lH_&M+X-k*OLzZiBGIK)O?(X*c QO-trsl89`WzOr2M3%#)H8vpehbYyYzk1;k z{W^DApdAt7?ZT7Q`%Yba_(h0t!%x)kUM+~E%zFOjUUs+ChEC9zG7a0(>13IVdy$_> zXCsuGPHR2Qyx0#D{nU-URyWCHk~!%{%UkZoaW|RkWO20DF+9%%n82qkiAN`q3+QOn?b6 z0Vco%m;e)C0!)AjFaajO1en18kbvJ7;?n^k9{&jE@&Et$_x~Sh#M1N0!)AjFaajO1egF5`2Gk~onokz=#MaSg%}E&YB%I| zN<||GWzl_TC=dzc3?(+Q%0s*RMd|t)hPCR zG$6yHnoDF+Uk28W6H2g-x5qnSLE&7ZTsAVl8Oeg}>fQ^JpbLl0JX~{FK`kSZ(d}ge zGx1|-4&lz%m*!>_5eD$$%5N90o?UA!u9V9yKe48doF((~nP!PfG!XD_6c7$p;q}(j z4%Kz-GU}9P$xp^=-`Axr{P}=e%zi-tyvp`=5_E*n{;9EC> zR|G$F%h#wHYTNar$b%ax=C1c8$m{bA&vuh_)K;rvYk0MrZ@8jwFdB-W+n0W;qwj1S zHCYPLga_iV5LbS*hFMYbBMb;q-J2d)7a4C`pCg#1A|^}Nq3%^g6<+|A`$gn))w#U5 zv~pIxjME!KYc3*Ht$O(kEuCLpU0GeL6=nk63U0MXhAJfAvfVuCtPMjuw$5H%caC((vs&e^k!STF-)l(6b8n`R=nO@MY5J41J*zZJb$ks} z7n?mBmJ*RtVBCNo2p--74gJ&*T(!5EUJ}BB@^|>4G=gomfnJGrn-L JCYPh~`5$Y`hQj~= literal 0 HcmV?d00001 diff --git a/httemplate/view/cust_main/custom_content/.svc_acct.html.swp b/httemplate/view/cust_main/custom_content/.svc_acct.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..e2db6d5d163daa8eec56f0d6d349c3a85b5ac63c GIT binary patch literal 12288 zcmeI&ze>YE90%}UU7SSGSvdbSErh1pLBzBaoE*eS7m;vHt~8KKV(;3}L0xsNEO7=!Kv~+_;ItMf`FYat_v5obM8F`q700bZa0SG_<0uX=z1pcFdPAhb8 zF1A!&Zn^9$Kl*Zr4gwH>00bZa0SG_<0uX=z1Rwx`1r*=`k-JKyP2~Uor{DkYX8dO2 z*~F8HM-#Uuio6B9CyopO2tWV=5P$##AOHafKmY;|_@jX9?1gctJ0vHy-LE3{-)HNr z&D_~bUGJFOa<^)S7_<7JhyrD?c86WvWHmNYViBYTk=Pk!Vc| Y<}I7tD$7SFiIhoP6wur3`;az$0`jhF4*&oF literal 0 HcmV?d00001 diff --git a/httemplate/view/cust_main/custom_content/.svc_hardware.html.swp b/httemplate/view/cust_main/custom_content/.svc_hardware.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..1106f9ed5fab6b64bd0efce7fa2ee8c476849a6c GIT binary patch literal 12288 zcmeI&O-sWt7zglYUOb7SXCc0=8gf6G$?4JCI*}anFdv@P zhJg?|=Gm;e+k8Q1m&u(j3mDK!{^00bZa0SG_<0uX=z1pcdljw^I$ z4!2MqaIwslU%BieK>z{}fB*y_009U<00Izz00bZ~hXULq+FvFLOyvLnKfnK9P5;Hj zqlpI-_a;Urin=*GCteu>5P$##AOHafKmY;|fB*y_@K*wDXGexocS%iZ+h4cc>#W0i z?jg0y$!eDvvxZUxUTU#UmtEduH6~-1dtSo)>?5Zlkvw4aYdf#jydQ|7*!p={-m5E8ESzsm3!zu-;9y$|;@}`ox`>7}z0!l+C7Nr4gSz=890eB_ zKZT#e#qZ%I#1^E`O{n}29`5ZSm-}rYPq%(?a?18=4YF;8==$*e?2UKmYn@1re4Q=N zYW+|M6Z`3`yoc<8ynic1B71@lj1ejheIxitij)V##CXb=Iv+*K3nFcVHar;xUOb4j zs11w?XPtt52tZ)Ez!Ej~cI(;R*5(FVTRoqihE)ha00Izz00bZa0SG|gUkaGGM344n z3&rggi@x-$FQ(`q009U<00Izz00bZa0SG_<0uY!(0l!Cdyi9a&Bm4jV^Zoy6=N~p+ zZM@icw((>m&zr-0;*}u)0SG_<0uX=z1Rwwb2tWV=e=N}CJ5o#2CN&w|Rkp|F?^V`f z9q)jeMOwK{j5&QN!d~LAR-0Ykq!pGI#OtAA)hjpKH-0x1`L;8zmv>xhmRUAEij<0U MUO(@$$x$wS1CGU8WdHyG literal 0 HcmV?d00001 diff --git a/httemplate/view/cust_main/custom_content/birthdate.html b/httemplate/view/cust_main/custom_content/birthdate.html new file mode 100644 index 000000000..1f16963af --- /dev/null +++ b/httemplate/view/cust_main/custom_content/birthdate.html @@ -0,0 +1,15 @@ + + <& /elements/tr-td-label.html, 'label' => mt('Date of Birth') &> + + +
<% $dt ? $dt->strftime($date_format) : '' %>
+<%init> +my($cust_main) = @_; +my $conf = new FS::Conf; +my $date_format = ($conf->config('date_format') || "%m/%d/%Y"); +my $dt = $cust_main->birthdate ne '' + ? DateTime->from_epoch( 'epoch' => $cust_main->birthdate, + 'time_zone' =>'floating', + ) + : ''; + diff --git a/httemplate/view/cust_main/custom_content/small_custview.html b/httemplate/view/cust_main/custom_content/small_custview.html new file mode 100644 index 000000000..b325f2ac7 --- /dev/null +++ b/httemplate/view/cust_main/custom_content/small_custview.html @@ -0,0 +1,8 @@ +<& /elements/small_custview.html, $cust_main &> +<%init> + +my($cust_main) = @_; + +my $conf = new FS::Conf; + + diff --git a/httemplate/view/cust_main/custom_content/spouse_birthdate.html b/httemplate/view/cust_main/custom_content/spouse_birthdate.html new file mode 100644 index 000000000..c78fd26a5 --- /dev/null +++ b/httemplate/view/cust_main/custom_content/spouse_birthdate.html @@ -0,0 +1,15 @@ + + <& /elements/tr-td-label.html, 'label' => mt('Spouse Date of Birth') &> + + +
<% $dt ? $dt->strftime($date_format) : '' %>
+<%init> +my($cust_main) = @_; +my $conf = new FS::Conf; +my $date_format = ($conf->config('date_format') || "%m/%d/%Y"); +my $dt = $cust_main->spouse_birthdate ne '' + ? DateTime->from_epoch( 'epoch' => $cust_main->spouse_birthdate, + 'time_zone' =>'floating', + ) + : ''; + diff --git a/httemplate/view/cust_main/custom_content/svc_Common.html b/httemplate/view/cust_main/custom_content/svc_Common.html new file mode 100644 index 000000000..519a395c7 --- /dev/null +++ b/httemplate/view/cust_main/custom_content/svc_Common.html @@ -0,0 +1,40 @@ +% foreach my $cust_svc (@cust_svc) { +% my $svc_x = $cust_svc->svc_x; +% #warn $svc_x; + +% foreach my $field ( grep $svc_x->$_(), @{ $opt{fields} } ) { + <& /elements/tr-td-label.html, 'label' => $labels{$field} &> + + +% } +
<% $svc_x->$field() |h %>
+% } +<%init> +my($cust_main, %opt) = @_; + +my $table = $opt{table}; +warn $table; +my @cust_svc = (); +foreach my $cust_pkg ( + grep {warn $_->num_cust_svc( 'svcdb'=>$table ); $_->num_cust_svc( 'svcdb'=>$table ); } + $cust_main->all_pkgs +) { + my @wtf = $cust_pkg->cust_svc( 'svcdb'=>$table ); + warn scalar(@wtf); + push @cust_svc, $cust_pkg->cust_svc( 'svcdb'=>$table ); +} + +my %labels; +if ( UNIVERSAL::can("FS::$table", 'table_info') ) { +# $opt{'name'} = "FS::$table"->table_info->{'name'}; + + my $fields = "FS::$table"->table_info->{'fields'}; + %labels = map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } + keys %$fields; +} + + diff --git a/httemplate/view/cust_main/custom_content/svc_acct.html b/httemplate/view/cust_main/custom_content/svc_acct.html new file mode 100644 index 000000000..49b97986d --- /dev/null +++ b/httemplate/view/cust_main/custom_content/svc_acct.html @@ -0,0 +1,7 @@ +<& svc_Common.html, $cust_main, + 'table' => 'svc_acct', + 'fields' => [qw( username _password )], +&> +<%init> +my($cust_main) = @_; + diff --git a/httemplate/view/cust_main/custom_content/svc_hardware.html b/httemplate/view/cust_main/custom_content/svc_hardware.html new file mode 100644 index 000000000..f5d53a251 --- /dev/null +++ b/httemplate/view/cust_main/custom_content/svc_hardware.html @@ -0,0 +1,7 @@ +<& svc_Common.html, $cust_main, + 'table' => 'svc_hardware', + 'fields' => [qw( ip_addr hw_addr serial )], +&> +<%init> +my($cust_main) = @_; + diff --git a/httemplate/view/cust_main/custom_content/svc_phone.html b/httemplate/view/cust_main/custom_content/svc_phone.html new file mode 100644 index 000000000..46ec476bc --- /dev/null +++ b/httemplate/view/cust_main/custom_content/svc_phone.html @@ -0,0 +1,7 @@ +<& svc_Common.html, $cust_main, + 'table' => 'svc_phone', + 'fields' => [qw( phonenum )], +&> +<%init> +my($cust_main) = @_; + -- 2.11.0