@@ -128,6 +128,8 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
128128 $ form ->addElement (new \XoopsFormHidden ('ttpl_amountout[0] ' , '0 ' ));
129129 $ crTratemplates = new \CriteriaCompo ();
130130 $ crTratemplates ->add (new \Criteria ('ttpl_online ' , 1 ));
131+ $ crTratemplates ->add (new \Criteria ('ttpl_class ' , Constants::CLASS_BOTH ));
132+ $ crTratemplates ->add (new \Criteria ('ttpl_class ' , $ traClass ), 'OR ' );
131133 $ tratemplatesAll = $ helper ->getHandler ('Tratemplates ' )->getAll ($ crTratemplates );
132134 foreach ($ tratemplatesAll as $ tratemplate ) {
133135 $ tplId = $ tratemplate ->getVar ('ttpl_id ' );
@@ -140,7 +142,7 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
140142 }
141143 $ tratemplatesSelect = new \XoopsFormRadio (\_MA_WGSIMPLEACC_TRANSACTION_TEMPLATE , 'tra_template ' , 0 );
142144 $ tratemplatesSelect ->addOption (0 , \_MA_WGSIMPLEACC_TEMPLATE_NONE );
143- $ tratemplatesSelect ->addOptionArray ($ tratemplatesHandler ->getList ());
145+ $ tratemplatesSelect ->addOptionArray ($ tratemplatesHandler ->getList ($ crTratemplates ));
144146 $ tratemplatesSelect ->setExtra (" onchange='presetTraField()' " );
145147 $ form ->addElement ($ tratemplatesSelect , true );
146148 }
@@ -177,11 +179,6 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
177179 $ form ->addElement ($ traDesc );
178180 // Form Editor DhtmlTextArea traRemarks
179181 $ editorConfigs = [];
180- if ($ isAdmin ) {
181- $ editor = $ helper ->getConfig ('editor_admin ' );
182- } else {
183- $ editor = $ helper ->getConfig ('editor_user ' );
184- }
185182 $ editorConfigs ['name ' ] = 'tra_remarks ' ;
186183 $ editorConfigs ['value ' ] = $ this ->getVar ('tra_remarks ' , 'e ' );
187184 $ editorConfigs ['rows ' ] = 5 ;
@@ -222,19 +219,20 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
222219 $ traAmountin = $ this ->isNew () ? $ default0 : Utility::FloatToString ($ this ->getVar ('tra_amountin ' ));
223220 // Form Text traAmountout
224221 $ traAmountout = $ this ->isNew () ? $ default0 : Utility::FloatToString ($ this ->getVar ('tra_amountout ' ));
225- if ( $ admin ) {
226- $ form -> addElement ( new \XoopsFormText (\ _MA_WGSIMPLEACC_TRANSACTION_AMOUNTIN , 'tra_amountin ' , 20 , 150 , $ traAmountin ) );
227- $ form -> addElement ( new \ XoopsFormText (\ _MA_WGSIMPLEACC_TRANSACTION_AMOUNTOUT , ' tra_amountout ' , 20 , 150 , $ traAmountout ) );
228- } else {
229- if (Constants:: CLASS_INCOME == $ type || Constants:: CLASS_INCOME == $ traClass || Constants:: CLASS_BOTH == $ type ) {
230- $ form -> addElement ( new \ XoopsFormText (\ _MA_WGSIMPLEACC_TRANSACTION_AMOUNTIN , ' tra_amountin ' , 20 , 150 , $ traAmountin ));
231- $ form -> addElement ( new \ XoopsFormHidden ( ' tra_amountout ' , 0 )) ;
232- }
233- if (Constants:: CLASS_EXPENSES == $ type || Constants:: CLASS_EXPENSES == $ traClass || Constants:: CLASS_BOTH == $ type ) {
234- $ form -> addElement ( new \ XoopsFormText (\ _MA_WGSIMPLEACC_TRANSACTION_AMOUNTOUT , ' tra_amountout ' , 20 , 150 , $ traAmountout ));
235- $ form -> addElement ( new \ XoopsFormHidden ( ' tra_amountin ' , 0 ));
236- }
222+ // Form Select traClass
223+ $ traClassSelect = new \XoopsFormRadio (\ _MA_WGSIMPLEACC_TRANSACTION_CLASS , 'tra_class ' , $ traClass );
224+ $ traClassSelect -> addOption (Constants:: CLASS_EXPENSES , \ _MA_WGSIMPLEACC_CLASS_EXPENSES );
225+ $ traClassSelect -> addOption (Constants:: CLASS_INCOME , \ _MA_WGSIMPLEACC_CLASS_INCOME );
226+ $ form -> addElement ( $ traClassSelect );
227+ // Form Text traAmount
228+ $ traAmount = 0 ;
229+ if (Constants:: CLASS_INCOME == $ type || Constants:: CLASS_INCOME == $ traClass || Constants:: CLASS_BOTH == $ type ) {
230+ $ traAmount = $ traAmountin ;
231+ }
232+ if (Constants:: CLASS_EXPENSES == $ type || Constants:: CLASS_EXPENSES == $ traClass || Constants:: CLASS_BOTH == $ type ) {
233+ $ traAmount = $ traAmountout ;
237234 }
235+ $ form ->addElement (new \XoopsFormText (\_MA_WGSIMPLEACC_TRANSACTION_AMOUNT , 'tra_amount ' , 20 , 150 , $ traAmount ));
238236 if ($ helper ->getConfig ('use_taxes ' )) {
239237 // Form Table taxes
240238 $ taxesHandler = $ helper ->getHandler ('Taxes ' );
@@ -249,8 +247,6 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
249247 $ traAsidSelect = new \XoopsFormSelect (\_MA_WGSIMPLEACC_TRANSACTION_ASID , 'tra_asid ' , $ traAsid );
250248 $ traAsidSelect ->addOptionArray ($ assetsHandler ->getList ());
251249 $ form ->addElement ($ traAsidSelect );
252- // Form Text traClass
253- $ traClass = $ this ->isNew () ? 0 : $ this ->getVar ('tra_class ' );
254250 // Form Text traComments
255251 $ traComments = $ this ->isNew () ? 0 : $ this ->getVar ('tra_comments ' );
256252 // Form Text traBalid
@@ -272,13 +268,7 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
272268 $ traStatusSelect ->addOption (Constants::STATUS_APPROVED , \_MA_WGSIMPLEACC_STATUS_APPROVED );
273269 $ traStatusSelect ->addOption (Constants::STATUS_LOCKED , \_MA_WGSIMPLEACC_STATUS_LOCKED );
274270 $ form ->addElement ($ traStatusSelect );
275- // Form Select traClass
276- $ traClassSelect = new \XoopsFormSelect (\_MA_WGSIMPLEACC_TRANSACTION_CLASS , 'tra_class ' , $ traClass );
277- $ traClassSelect ->addOption (Constants::CLASS_BOTH , \_MA_WGSIMPLEACC_CLASS_BOTH );
278- $ traClassSelect ->addOption (Constants::CLASS_EXPENSES , \_MA_WGSIMPLEACC_CLASS_EXPENSES );
279- $ traClassSelect ->addOption (Constants::CLASS_INCOME , \_MA_WGSIMPLEACC_CLASS_INCOME );
280- $ form ->addElement ($ traClassSelect );
281- // Form Select traClass
271+ // Form Select traBalid
282272 $ traBalidSelect = new \XoopsFormSelect (\_MA_WGSIMPLEACC_TRANSACTION_BALID , 'tra_balid ' , $ traBalid );
283273 $ balancesHandler = $ helper ->getHandler ('Balances ' );
284274 $ traBalidSelect ->addOption (0 , '' );
@@ -300,7 +290,6 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
300290 $ form ->addElement (new \XoopsFormLabel (_MA_WGSIMPLEACC_TRANSACTION_STATUS , Utility::getStatusText ($ traStatus )));
301291 }
302292 $ form ->addElement (new \XoopsFormHidden ('tra_status ' , $ traStatusNew ));
303- $ form ->addElement (new \XoopsFormHidden ('tra_class ' , $ traClass ));
304293 $ form ->addElement (new \XoopsFormHidden ('tra_balid ' , $ traBalid ));
305294 $ form ->addElement (new \XoopsFormHidden ('tra_comments ' , $ traComments ));
306295 $ form ->addElement (new \XoopsFormHidden ('tra_hist ' , $ traHist ));
@@ -312,6 +301,8 @@ public function getFormTransactions($action = false, $admin = false, $type = 0,
312301 $ form ->addElement (new \XoopsFormHidden ('op ' , 'save ' ));
313302 if ($ approve ) {
314303 $ form ->addElement (new \XoopsFormButtonTray ('' , \_MA_WGSIMPLEACC_APPROVE , 'submit ' , '' , false ));
304+ } elseif (Constants::STATUS_OFFLINE == $ traStatus ) {
305+ $ form ->addElement (new \XoopsFormButtonTray ('' , \_MA_WGSIMPLEACC_REACTIVATE , 'submit ' , '' , false ));
315306 } else {
316307 $ form ->addElement (new \XoopsFormButtonTray ('' , \_SUBMIT , 'submit ' , '' , false ));
317308 }
0 commit comments