@@ -13,7 +13,7 @@ class CRM_Admin_Form_Setting_Receipt extends CRM_Admin_Form_Setting {
13
13
*/
14
14
public function buildQuickForm () {
15
15
CRM_Utils_System::setTitle (ts ('Settings - Contribution Receipt ' ));
16
- $ this ->addElement ('text ' , 'receiptLogo ' , ts ('Logo ' ));
16
+ $ this ->addElement ('file ' , 'receiptLogo ' , ts ('Logo ' ));
17
17
$ this ->addElement ('text ' , 'receiptPrefix ' , ts ('Prefix of Receipt ID ' ));
18
18
$ this ->addElement ('textarea ' , 'receiptDescription ' , ts ('Description of Receipt Footer ' ));
19
19
$ this ->addElement ('textarea ' , 'receiptOrgInfo ' , ts ('Organization info ' ));
@@ -59,18 +59,28 @@ public function buildQuickForm() {
59
59
$ this ->add ('file ' , 'uploadBigStamp ' , ts ('The stamp of organization. ' ));
60
60
$ this ->add ('file ' , 'uploadSmallStamp ' , ts ('The stamp of the person in charge. ' ));
61
61
$ config = CRM_Core_Config::singleton ();
62
- $ this ->controller ->addActions ($ config ->imageUploadDir , array ('uploadBigStamp ' , 'uploadSmallStamp ' ));
62
+ $ this ->controller ->addActions ($ config ->imageUploadDir , array ('uploadBigStamp ' , 'uploadSmallStamp ' , ' receiptLogo ' ));
63
63
64
64
if ($ config ->imageBigStampName ){
65
65
$ this ->assign ('imageBigStampUrl ' , $ config ->imageUploadURL . $ config ->imageBigStampName );
66
66
}
67
67
if ($ config ->imageSmallStampName ){
68
68
$ this ->assign ('imageSmallStampUrl ' , $ config ->imageUploadURL . $ config ->imageSmallStampName );
69
69
}
70
+ $ receiptLogo = $ config ->receiptLogo ;
71
+ if ($ receiptLogo ) {
72
+ if (substr ($ receiptLogo , 0 , 7 ) == 'http:// ' || substr ($ receiptLogo , 0 , 8 ) == 'https:// ' ) {
73
+ $ this ->assign ('receiptLogoUrl ' , $ receiptLogo );
74
+ }
75
+ else if ($ receiptLogo ) {
76
+ $ this ->assign ('receiptLogoUrl ' , $ config ->imageUploadURL . $ receiptLogo );
77
+ }
78
+ }
70
79
71
80
$ this ->assign ('stampDocUrl ' , CRM_Utils_System::docURL2 ('Receipt Stamp ' , TRUE ));
72
81
$ this ->add ('hidden ' , 'deleteBigStamp ' );
73
82
$ this ->add ('hidden ' , 'deleteSmallStamp ' );
83
+ $ this ->add ('hidden ' , 'deleteReceiptLogo ' );
74
84
75
85
$ displayLegalIDOptions = array ('complete ' => ts ('Complete display ' ), 'partial ' => ts ('Partial hide ' ), 'hide ' => ts ('Complete hide ' ));
76
86
$ this ->addRadio ('receiptDisplayLegalID ' , ts ('The way displays legal ID in receipt. ' ), $ displayLegalIDOptions );
@@ -92,6 +102,7 @@ function setDefaultValues() {
92
102
$ defaults = parent ::setDefaultValues ();
93
103
$ defaults ['deleteBigStamp ' ] = '' ;
94
104
$ defaults ['deleteSmallStamp ' ] = '' ;
105
+ $ defaults ['deleteReceiptLogo ' ] = '' ;
95
106
if (empty ($ defaults ['receiptDisplayLegalID ' ])) {
96
107
$ defaults ['receiptDisplayLegalID ' ] = 'complete ' ;
97
108
}
@@ -125,17 +136,25 @@ public function postProcess() {
125
136
$ uploadSmallStamp = CRM_Utils_Array::value ('uploadSmallStamp ' , $ params );
126
137
$ uploadSmallStamp = $ uploadSmallStamp ['name ' ];
127
138
139
+ $ uploadReceiptLogo = CRM_Utils_Array::value ('receiptLogo ' , $ params );
140
+ $ uploadReceiptLogo = $ uploadReceiptLogo ['name ' ];
141
+
128
142
$ deleteBigStamp = CRM_Utils_Array::value ('deleteBigStamp ' , $ params );
129
143
$ deleteSmallStamp = CRM_Utils_Array::value ('deleteSmallStamp ' , $ params );
144
+ $ deleteReceiptLogo = CRM_Utils_Array::value ('deleteReceiptLogo ' , $ params );
130
145
unset($ params ['deleteBigStamp ' ]);
131
146
unset($ params ['deleteSmallStamp ' ]);
147
+ unset($ params ['deleteReceiptLogo ' ]);
132
148
133
149
if ($ deleteBigStamp ){
134
150
$ params ['imageBigStampName ' ] = '' ;
135
151
}
136
152
if ($ deleteSmallStamp ){
137
153
$ params ['imageSmallStampName ' ] = '' ;
138
154
}
155
+ if ($ deleteReceiptLogo ){
156
+ $ params ['receiptLogo ' ] = '' ;
157
+ }
139
158
140
159
// to check wether GD is installed or not
141
160
$ gdSupport = CRM_Utils_System::getModuleSetting ('gd ' , 'GD Support ' );
@@ -148,6 +167,10 @@ public function postProcess() {
148
167
$ error = false ;
149
168
$ params ['imageSmallStampName ' ] = $ this ->_resizeImage ($ uploadSmallStamp , "_full " , 800 , 200 );
150
169
}
170
+ if ($ uploadReceiptLogo ) {
171
+ $ error = false ;
172
+ $ params ['receiptLogo ' ] = $ this ->_resizeImage ($ uploadReceiptLogo , "_full " , 800 , 200 );
173
+ }
151
174
}else {
152
175
$ error = true ;
153
176
}
@@ -257,5 +280,4 @@ private function _resizeImage($filename, $resizedName, $width, $height ) {
257
280
return basename ($ newFilename );
258
281
}
259
282
260
- }
261
-
283
+ }
0 commit comments