TYPO3 condition with session - typo3

I have this TypoSript:
Contance:
finish_day_value = TSFE:fe_user|sesData|finish_day
Setup:
plugin.Tx_Formhandler.settings.predef.formhandler-multistep-forms {
if {
1 {
conditions.OR1 {
AND1 = {$finish_day_value} > 7
AND2 = {$finish_day_value} < 15
}
isTrue {
markers.input_readonly_a_price = CONTENT
markers.input_readonly_a_price {
table = tx_pricelist_prices_full
select {
pidInList = {$get_carpid}
orderBy = uid
selectFields = uid, group_a_8_14
# possible conditions
where = ( tx_pricelist_prices_full.uid='1' AND hidden='0' AND deleted='0')
}
renderObj = COA
renderObj {
#value
1 = TEXT
1.insertData = 1
1.data = field:group_a_8_14
2 = TEXT
2.value = *
3 = TEXT
3.insertData = 1
3.data = TSFE:fe_user|sesData|finish_day
stdWrap.prioriCalc = 1
}
}
}
}
}
}
The finish_day value is sending by the session from one form to another (that's why I use TSFE:fe_user|sesData|finish_day). But when I insert it to Setup (for example):
AND1 = TSFE:fe_user|sesData|finish_day > 7
AND2 = TSFE:fe_user|sesData|finish_day < 15
Nothings happens. So I try to define Constance value, but still nothing.
How to call the session value (finish_day) and use it on AND conditions?
Thanks for any help

What you want to do is very specific. It depends on the extension you use.
If for AND1 is stdWrap implemented, you can use:
AND1.data = TSFE:fe_user|sesData|finish_day
AND1.intval = 1
AND1.noTrimWrap = | | > 7|
data: imports the data of the session
intval: we expect an integer, no chance for sql-injection here
noTrimWrap: i do not know, if you need the extra spaces.

I used GlobalVar conditions:
[globalVar = TSFE:fe_user|sesData|finish_day > 0] && [globalVar = TSFE:fe_user|sesData|finish_day < 4 ]
...
ts
...
[global]

Related

TYPOSCRIPT stdWrap.replacement I Want to replace space with underscore _

My typo3 version is 10.4.22
lib.spaces = TEXT
lib.spaces {
current = 1
stdWrap.replacement {
10 {
search =
replace = _
wrap = |
}
}
}
I have a following typoscript. And now my question is, what i have to write in search = ?
so that space is being searched and replace with underscore.
SORRY For my bad english!
replacement.search has stdWrap, so you can use char. The ascii code for space is 32, so that will make it:
lib.spaces = TEXT
lib.spaces {
current = 1
stdWrap.replacement {
10 {
search.char = 32
replace = _
wrap = |
}
}
}

TYPO3 get usergroups with typoscript

I am trying to get the usergroup titles which belong to the current fe_user.
I have this script as an example, but it returns me all the usergroups.
If I only implement the first 3 lines, the correct usergroup uid comes out. What should be changed?
30 = TEXT
30.data = TSFE:fe_user|user|usergroup
30.required = 1
30.split {
token = ,
cObjNum = 1 || 2
1 {
10 = CONTENT
10.table = fe_groups
10.select.pidInList = 25
10.select.andWhere.current = 1
10.select.andWhere.wrap = uid=|
10.renderObj = TEXT
10.renderObj.field = title
10.renderObj.wrap = |,
}
2 < .1
2.10.renderObj.wrap >
}
Ok I found it, the problem was andWhere, it should be where.
30 = TEXT
30 {
data = TSFE:fe_user|user|usergroup
required = 1
split {
token = ,
cObjNum = 1
1.10 = CONTENT
1.10 {
table = fe_groups
select {
pidInList = {$pages.frontEndUsers}
where.current = 1
where.wrap = uid=|
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = |,
}
}
}

Crystal Reports Leaving out parameter

I have a crystal report that I am modifying the record selection formula. I have a parameter "Inventory_Class" that can have 3 values 0, 1 or 2. If set to 1 I want my DB field "NON_Controllable" that is binary field to select all False records, if the parameter is set to 2 then I want all True records but if the incoming parameter is set to 0 then I don't want to filter on the DB field "NON_Controllable" at all. I can get formula to work when parameter is set to 1 and 2 selecting Non_Controllable false and true records but when the parameter is set to 0 my report returns no records when it should be returning all records.
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD} and
IF ({?INVENTORY_CLASS} = 1) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = FALSE
ELSE IF ({?INVENTORY_CLASS} = 2) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = TRUE
ELSE IF ({?INVENTORY_CLASS} = 0) THEN
NOT {Inventory_Cat_Header.NON_CONTROLLABLE}
How can I modify this formula to work?
you can try passing the parameters for each conditions instead.
IF
({?INVENTORY_CLASS} = 1) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = FALSE and
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}
ELSE IF
({?INVENTORY_CLASS} = 2) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = TRUE and
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}
else
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}

Weird value from NSDictionary

I got a NSDictionary that when I do a [currentOrder debugDescription] call on it the layout is below, when I then do a:
[currentOrder valueForKey: #"itemOrder"]
It return it funny with the brackets as:
(
"4 X ESPRESSO"
)
where it should only be (without brackets):
4 X EXPRESSO
Any idea why?
Content of currentOrder:
currentOrder: <__NSArrayM 0x68426c0>(
{
extra1Select = 0;
extra2Select = 0;
extra3Select = 0;
itemCost = 58;
itemOrder = "4 X ESPRESSO";
itemOrderDescription = "Cookie: YES, Sugar: YES";
itemQuantity = 4;
itemRestaurant = VidaECaffe;
plistItem = {
cost = "11.5";
description = "R11.50";
extra1 = {
desc = Cookie;
details = (
{
cost = "3.00";
option1 = YES;
},
{
cost = "0.00";
option2 = NO;
}
);
};
extra2 = {
desc = Sugar;
details = (
{
cost = "0.00";
option1 = YES;
},
{
cost = "0.00";
option2 = NO;
}
);
};
itemRestaurant = VidaECaffe;
level = 1;
title = ESPRESSO;
};
}
)
The problem is that currentOrder is not a dictionary but a NSArray containing a dictionary. The failure you are making next is that you use valueForKey: which is part of the key value coding family and not the designated access method for dictionaries (which is objectForKey:), and the array returns you a filtered array as a result...
When you print out the value of an array or dictionary in the debugger, the debugger includes the extra brackets, braces, and whatnot so you can see the layout of the structure you are asking about.
If the debugger shows the contents of an array something like
(
"Foobar"
)
it's telling you that the array has one element, a string with the value Foobar.
Put entirely another way: Read up on what the debugger does when it prints out values. Lots of resources here and on the web for this. For example: Debugging with GDB: Introduction to Commands, Print and Print-Object

Can I put an if, elsif and else into set of one liners?

(using Perl) I have a set of statements:
if(#good_car) {
$goodC = 1;
}
elsif (#notbad_car) {
$okayC = 1;
}
else {
$badC = 1;
}
I was wondering if I could do something like:
$goodC = 1 if (#good_car),
elsif (#notbad_car) $okayC = 1 else $badC = 1;
I can't imagine this working really because of the elsif, but it would be nice to shorten it down a bit :) Any hints would be great!
#good_car ? ($goodC = 1) : #notbad_car ? ($okay = 1) : ($bad = 1);
There is no else that works with the statement-modifier form of if.
I would just change the indentation:
if (#good_car) { $goodC = 1 }
elsif (#notbad_car) { $okayC = 1 }
else { $badC = 1 }