Problem to write 2 email plugin when recipient1 is YES/NO on holiday

I need condition:
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
 
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id`='20' AND `status_zastepstwa1`='TAK'
AND  `data_zast_od1`<= NOW() AND `data_zast_do1`>=NOW() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 == 0;

But works correctly only this piece:
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
 
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE  `status_zastepstwa1`='TAK'
AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 == 0;

:(

what to do with:
WHERE `form_id`='20' AND `data_zast_od1`<= NOW() AND `data_zast_do1`>=NOW()
?
 
its your code,

data_zast_od1`<= NOW() AND `data_zast_do1`>=NOW()

will never match any results! except for those stored at the exact micro second that query is run! :eek:
 
Thanks Rob,
but i try also:
`data_zast_od1`<= CURDATE() AND `data_zast_do1`>=CURDATE() - this also doesn't work - always send email --- it means the code doesn't see records.

can you write me right condition - so i can't find this?
--------------------------------------------------------------
column1 = START DATE (for example 2013-07-01) =`data_zast_od1`
column2 = END DATE (for example 2013-07-27)= `data_zast_do1`

if we run query today ----> CURDATE()=2013-07-16 so it is between start and end date - it should see record

how to write this?
 
`data_zast_od1`<= CURDATE() AND `data_zast_do1`>=CURDATE()
that seems correct. So it must be something else.
Have you var_dumped the db object or checked to see if its producing and error
 
Hi Rob,

This is for problem1 --- email1 ( case when recipient1 is not on holiday - then email should be send to him)
-------------------------------------------------------------------------------------------------
In this moment works this:
condition:
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 == 0;

but i need :
form_id ---- {ccjom_cc_lista_zastepsw___form_id} --- that is cascading dropdown

when use `form_id` instead of `form_id1` (that is type "field") - it always send email - so it doesn't see records
---------------------------------------------------------------------------------------------------------
I am not sure how to var_dump an object `form_id` ?

i try this: (But i no get any error message)
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
$form_id='{ccjom_cc_lista_zastepstw___form_id_raw}';
var_dump($form_id);
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 == 0;
 

Attachments

  • Zaznaczenie_258.png
    Zaznaczenie_258.png
    28.5 KB · Views: 283
  • Zaznaczenie_259.png
    Zaznaczenie_259.png
    12.8 KB · Views: 298
  • Zaznaczenie_260a.png
    Zaznaczenie_260a.png
    54.1 KB · Views: 303
I have also problem2 (----it is my email2------)
case when recipient is on holiday an email should go to email address of substituted person:
I have:
email to (eval):
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
$form_id='{ccjom_cc_lista_zastepstw___form_id_raw}';
var_dump($form_id);
$query2 = "SELECT `email_zastep` FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK'
AND  `data_zas_od1`<= CURDATE()
AND `data_zas_do1`>= CURDATE()
AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2;

condition (is OK):
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
$form_id='{ccjom_cc_lista_zastepstw___form_id_raw}';
var_dump($form_id);
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20'
AND `status_zastepstwa1`='TAK'
AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE()
AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 > 0;

It doesn't send an email to email address of substituted person but return error:
Could not send email to 48, invalid address

It should send because i try case when is record in `ccjom_cc_lista_zastepstw`

------> this is similar problem like "form_id1, form_id".
This doesn't work because in email to (eval) is field `email_zastep` that is cascadingdropdown - if i use instead of `email_zastep` field `email_test` that is type: "field" then issue=problem2=email2 works,


----------------------------------------------------------------------------
It is still problem with field form_id but i use form_id1 to simplificy issue.

`ccjom_cc_lista_zastepstw` = List of substituted person
Zast?puj?cy = Substituted person
Email zast?puj?cego = Substituted person email


*************************************
So problem is with 2 fields that i need them to be cascadingdropdown --- how to solve this?
 

Attachments

  • Zaznaczenie_261.png
    Zaznaczenie_261.png
    39.2 KB · Views: 282
  • Zaznaczenie_263a.png
    Zaznaczenie_263a.png
    130.5 KB · Views: 278
Hi, i really need this 2 email plugin and i suppose problem is with fabrik - so, mysql queries work wrong when i use fields "email_zastep" and "form_id" that are cascading dropdown.
When try test and use fields (instead of those) that are only type "fields" no cascading dropdown everything work properly.

My email1 (condition) is in post #26
My email2 (email to eval + condition) is in post #27.

Is possibly to done something to have my 2 email plugin working with those fields cascadingdropdown?
 
Can you find me on the live chat or Skype, and show me where these plugins are on your site. I'm getting lost trying to find them. It's the whole Polish language / naming thing.

-- hugh
 
Here is a form that use this 2 email plugin:
http://194.181.162.166/cc.joomla/index.php/zapotrzebowanie-artykul/zapotrzebowanie-zamform-iso

Here is this form in admin panel:
http://194.181.162.166/cc.joomla/ad...option=com_fabrik&view=form&layout=edit&id=20

in admin panel on form are:
email - not published - not important version
redirect
email - not published - not important version
email - email1 - send to worker when he is not on holidays
email - email2 - send to substituted person - when "first worker" is on holiday

here is a list - "list of workers on holiday and persons substituted them in different tasks - different tasks are given by different forms"
http://194.181.162.166/cc.joomla/index.php/lista-zastepstw-pracow

here is this list in admin panel:
http://194.181.162.166/cc.joomla/ad...ption=com_fabrik&view=list&layout=edit&id=167

Here are lelement to list "workers on holidays and substituted them person":
http://194.181.162.166/cc.joomla/administrator/index.php?option=com_fabrik&view=elements

there is a problem with elements:
3166 form_id
3159 email_zastep
that are cascadingdropdown.

Some elements in this "elements list" are only for tests purposes - i try use different elements - type field - not type cascadingdropdown and then my email plugins work properly,
I need cascading dropdown because worker that is going to holiday - points in this table substituted person and email of substituted person should go automaticly to this list (as cascading dropdown from list/table with users)
workers that is going to holiday can write more than 1 record in table with "holidays" because for issue on form id=22 substituted him person can be s_person1 and for issue on form id=20 substituted him person can be s_person2.
Also worker that is going to holiday choose from list: name of issue (it is something similar to form name) and automaticly should go to form_id (as cascading dropdown) that we use in mysql query to email plugin.

list of issue that should be substituted is here:
http://194.181.162.166/cc.joomla/administrator/index.php?option=com_fabrik&task=list.view&listid=173
 
OK, I've looked at your code. I can't really test it, as I don't know which user to test as, to generate which condition (on holiday).

But what I suggest is, instead of placeholders, use Fabrik's getElementData() method:

PHP:
$form_id = $formModel->getElementData('ccjom_cc_lista_zastepstw___form_id', true);

... which should (I think) solve the issue. I don't actually see anywhere in your code where you are using the 'email_zastep' element, except as a field name in a query, but if you do use that as a placeholder anywhere, do the same thing with that, and get the value using getElementData() rather than a placeholder.

If that doesn't work, do a ...

var_dump($query2);exit;

... before the 'return' at the end of code, and paste the output here, along with the exact code you were running at the time.

We may still need to get together on Skype / chat, so you can walk me through how to test this form, in order to generate the various desired test cases / outcomes.

My apologies that this is taking a while, but the language issue is a huge problem for me. I just get utterly lost when I try and work on your site, as it's like trying to work on a completely alien site, where nothing makes sense. I don't know what the app is doing, none of the form / element / list names mean anything, it's all just a jumble of random letters! And of course, when we try and discuss the issues on the forum the language barrier doesn't help either. I don't have this problem when dealing with (say) French, or Spanish, or Italian ... as I have at least some grasp of whats going on, enough of the language makes sense that I can find my way around.

It's hard to explain why it's such a problem. It's not necessarily that I understand (say) Italian, but for example, if I'm dealing with a specific form and element name, I can at least phonetically remember how they are spelled, find them in lists, write them, and "pattern match" them visually in most European languages. But in Polish, I'm just trying to deal with what to me is a meaningless jumble of letters that don't make any sense what so ever, and even finding a specific name in a list becomes a major problem.

-- hugh
 
This works:
-----------------------------------------------------------------------------------------------------
email1: email to worker - send - when worker is not on holiday
Email to eval: ---1---
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
$query1 = "SELECT `email` FROM `ccjom_users` WHERE `id` = " . $db->Quote($recipient1);
$db->setQuery($query1);
$result1 = $db->loadResult();
return $result1;
Condition: ---2---
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
 
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 == 0;
---------------------------------------------------------------------------------------------------------
email2: ---3---
Email to eval: email send to substituted person - when worker is on holiday
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
 
$query2 = "SELECT `email_testcalc` FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2;
Condition: ---4---
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
 
$query2 = "SELECT COUNT(`email_zastep`) AS tot FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2 > 0;
--------------------------------------------------------------------------------------------------------------------------------
I use:
form_id1='20' that is type field
email_testcalc - that is type calc to email_zastep (that is cascading dropdown)

when use email_zastep instead of email_testcalc i get error:
email2: ---3---
Email to eval: email send to substituted person - when worker is on holiday
PHP:
$db =& JFactory::getDBO();
$recipient1 = '{ccjom_cc_zapotrzebowanie___recipient1_raw}';
var_dump($recipient1);
 
$query2 = "SELECT `email_zastep` FROM
`ccjom_cc_lista_zastepstw` WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);
$db->setQuery($query2);
$result2 = $db->loadResult();
return $result2;
iget an error:
PHP:
Could not send email to 48, invalid address
--------------------------------------
for beginning we can stay with field form_id1='20' that is type "field"

Is possible to do something to make possibly use field email_zastep that is cascading dropdown - not with added field email_testcalc that is calc?
 

Attachments

  • Zaznaczenie_277.png
    Zaznaczenie_277.png
    66.5 KB · Views: 274
  • Zaznaczenie_279.png
    Zaznaczenie_279.png
    62.5 KB · Views: 275
Try this as your query:

Code:
$query2 = " SELECT #__users.email FROM
`ccjom_cc_lista_zastepstw` LEFT JOIN #__users ON #__users.id = ccjom_cc_lista_zastepstw.email_zastep WHERE `form_id1`='20' AND `status_zastepstwa1`='TAK' AND  `data_zas_od1`<= CURDATE() AND `data_zas_do1`>= CURDATE() AND  `osoba_zastepowana` = " . $db->Quote($recipient1);

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top