Doesn't work "if contains "word" " in CALC element,

Hi,
I have a problem for my calc element with code:
PHP:
$db =& JFactory::getDBO();
$tp5 = '{ccjom_cc_lista_zastepstw___Field_mix}';
$a = 'Zapotrzebowanie';
$b = 'Cele';
 
if ($tp5 contains "Zapotrzebowanie"){
  return "aaaa";
}

This return nothing, and should return "aaaa".

Problem is in my opinion with "contains" --- i need to use this and i don't use it earlier in CALC element.
What can i modify in my code for CALC?

added:
Doesn't work also this:
PHP:
$db =& JFactory::getDBO();
$tp5 = '{ccjom_cc_lista_zastepstw___Field_mix}';
$a = 'Zapotrzebowanie';
$b = 'Cele';
 
if ('{ccjom_cc_lista_zastepstw___Field_mix}' CONTAINS "Zapotrzebowanie"){
  return "aaaa";
}
 
Hi,
I will write this more exactly:
My element {ccjom_cc_lista_zastepstw___task_all} that is a picklist element includes 10 values as on screen-shoot.
One of those values is "Zapotrzebowanie".
I need in my calc element check if "on picklist" was checked "Zapotrzebowanie" and if was then return some words for example "aaaaaa bbbb"

It seems "CONTAINS" is not good for picklist for this condition but i have problem what different to find and how use something else for this.
Remark: I need just picklist element not checkbox in this case.

This doesn't work:

$db =& JFactory::getDBO();
$tp5 = '{ccjom_cc_lista_zastepstw___task_all}';

if ($tp5 CONTAINS "Zapotrzebowanie"){
return "aaaaaa bbbb";
}
Can you help me to modify this?
 

Attachments

  • Zaznaczenie_001.png
    Zaznaczenie_001.png
    52.2 KB · Views: 407
Hi,

Your element probably returns an array. You may verify using :
var_dump($tp5);exit;


If I'm right I would suggest :

PHP:
if (in_array("Zapotrzebowanie", $tp5)) {
return "aaaaaa bbbb";
}
Also I don't think the line $db =& JFactory::getDBO(); is relevant except the remind script is actually accessing the db
 
Very thanks Icollong for tip.
Now i am working with code:
Code:
$db = JFactory::getDBO();
$tp5 = '{ccjom_cc_lista_zastepstw___task_all}';
 
if (strpos($tp5, 'Zapotrzebowanie') !== false) {
 
return 'aaaaaa bbbb';
 
}
that i get in PM from "myfatebiz" who is from "community level".
This code works and i now make something more complex with this code - and this works also, although may be is possible to write this more simply.

I will write here my new code2 after about 1 hour,
 
Hi,
My exact complex code is this:
PHP:
$db =& JFactory::getDBO();
 
$tp5 = '{ccjom_cc_lista_zastepstw___Field_mix}';
 
if (strpos($tp5, 'Zapotrzebowanie') == false){
$p1 = "-Zapotrzebowanie-,";}
else {
$p1 = " ";}
 
if (strpos($tp5, 'Niezgodno?ci') == false){
$p2 = "-Niezgodno?ci-,";}
else {
$p2 = " ";}
 
if (strpos($tp5, 'Cele') == false){
$p3 = "-Cele-,";}
else {
$p3 = " ";}
 
if (strpos($tp5, 'Wyposa?enie pomiarowe') == false){
$p4 = "-Wyposa?enie pomiarowe-,";}
else {
$p4 = " ";}
 
if (strpos($tp5, '?rodki ochrony osobistej') == false){
$p5 = "-?rodki ochrony osobistej-,";}
else {
$p5 = " ";}
 
if (strpos($tp5, 'Szkolenie, ocena, harmonogram') == false){
$p6 = "-Szkolenie, ocena, harmonogram-,";}
else {
$p6 = " ";}
 
if (strpos($tp5, 'Macierz dokumentacji') == false){
$p7 = "-Macierz dokumentacji-,";}
else {
$p7 = " ";}
 
if (strpos($tp5, 'Zg?oszenie naprawy') == false){
$p8 = "-Zg?oszenie naprawy-,";}
else {
$p8 = " ";}
 
if (strpos($tp5, 'Reklamacja sposobu dzia?ania urz?dzenia') == false){
$p9 = "-Reklamacja sposobu dzia?ania urz?dzenia-,";}
else {
$p9 = " ";}
 
if (strpos($tp5, 'Sugestie') == false){
$p10 = "-Sugestie-,";}
else {
$p10 = " ";}
 
 
return $p1." ".$p2." ".$p3." ".$p4." ".$p5." ".$p6." ".$p7." ".$p8." ".$p9." ".$p10;

What i exactly need is to share "ISO tasks" for two persons: Person1a and Person2a. We have actually 10 "ISO tasks" that should be shared and assigned to "substituted persons = Person1a and Person2a".
When Worker_xyz goes to holiday he/she should point two persons (from our other workers): Person1a and assigns him/her tasks in field =picklist and Person2a and assigns him/her tasks in field=calc_element (calc should be = "not checked tasks on picklist" = "10 - "checked on picklist"".
We want to see on list tasks both for Person1a and for Person2a they are responsible for them - see screenshoot.


I don't know if this code can be written more simply?

Remarks:
I wait for opinion/decision of my co-workers/bosses if is enought two person: Person1a and Person2a or if they need possibility to point up to three persons : Person1a, Person2a, Person3a - what need probably writting new "pick3list" plugin, ;-)
 

Attachments

  • Zaznaczenie_002.png
    Zaznaczenie_002.png
    110.1 KB · Views: 404
  • Zaznaczenie_003.png
    Zaznaczenie_003.png
    38 KB · Views: 396
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top