schaeff
|
| Posted: 05/05/2002, 5:13 AM |
|
As mentioned in an earlier thread I am trying to set a label (currently logged in user name and time of last login) in the header. I put the following code in Header_BeforeShow():
$test = new clsDBEsperto;
$SQL = "SELECT login, MAX(start) as starttime
FROM Users LEFT JOIN Arbeitszeiten ON Users.user_id = Arbeitszeiten.user_id
WHERE Arbeitszeiten.planzahl = 'N'
AND Users.user_id = " . CCtosql(CCGetSession("UserID"),ccsInteger) . "
GROUP BY login;";
$test->query($SQL);
$test->next_record();
Now how can I access the values of the labels named "Username" and "Starttime" int the header to set them to $test->f("login") and $test->("starttime") respectively?
|
|
|
 |
Nicole
|
| Posted: 05/06/2002, 7:11 AM |
|
Hello,
my suggestion is to use CCDLookUp() function (you'll find it in common.php). Here is sample of before shpw event:
Note, that you should open new connection and define form name (or field name if it is located outside form) as global variable. I didn't try to use separate field, only field inside form, so the example is for the form field
$dbl = new clsDB<connection_name>();
global $<form_name>;
if (CCGetUserID())
{
$name_user = CCDlookUp("lookup_field", "table_name", "primary_key_field = ". CCGetUserID(), $dbl);
$<form_name>-><field_name>->SetValue($name_user);
}
|
|
|
 |
schaeff
|
| Posted: 05/09/2002, 3:27 AM |
|
Thanks for your suggestions. Unfortunately I still don't get it to work:
CCDlookUp works fine.
My lable is called "User", but when trying to address with
global $User;
$User->SetValue(...);
I get:
Fatal error: Call to a member function on a non-object in /vol/httpd/esperto/dev/esperto3/Header_events.php on line 38
which is the SetValue-line
Now, how do I insert a form in CCS. I can either choose the form element from the HTML Toolbox or change the HTML source manually. Both don't give me a variable or class in the code that I can refer to leading to the same error as shown above.
Since I found no other way to insert a form I can refer to I tried to put in a record or a grid. I tried defining a table as data source for these elements as well as the SQL statement I used in the first place or leaving the data source all blank. No matter what I tried I always got:
Fatal error: Cannot instantiate non-existent class: clsrecorduserinfo in /vol/httpd/esperto/dev/esperto3/Header.php on line 62
or
Fatal error: Cannot instantiate non-existent class: clsgriduserinfo in /vol/httpd/esperto/dev/esperto3/Header.php on line 62
I really do not know what I am doing wrong. Why don't that classes get created automatically, how can I insert a form in CCS that I can refer to?
Thanks for your help!
|
|
|
 |
Nicole
|
| Posted: 05/09/2002, 6:59 AM |
|
Hello,
try to add form to the page, but do no select Connection and DataSource for it. Then place label field to it and follow my previous instructions
|
|
|
 |
schaeff
|
| Posted: 05/09/2002, 8:13 AM |
|
But How do I add a form?
There ist only a form in the HTML toolbox. Inserting that does not give me a properties window for the form and thus I cannot give it a name.
Of course I can do all this manually but that does not add any code, so the form is not known to php.
How do I add a form?
|
|
|
 |
Nicole
|
| Posted: 05/10/2002, 5:52 AM |
|
Hello,
to add form to the page, go to ToolBox window->Components tab, select 'Add Record Form' and drag it to the page. You do not need specify any settings except name and Theme. Just add label field to it.
|
|
|
 |
schaeff
|
| Posted: 05/10/2002, 1:40 PM |
|
Thanks again for your help.
I did just what you suggested with the following result (name of the form is UserInfo):
Fatal error: Cannot instantiate non-existent class: clsrecorduserinfo in /vol/httpd/esperto/dev/esperto3/Header.php on line 57
This is the same problem I got with the search forms I included in the header. Only way to get around it seems to be to add the class code manually.
Playing around with the settings I found that those missing classes do get generated when I change the page's Includeable property to "No". Then of course I get problems using this page as header:
Fatal error: Cannot redeclare class clssqlparameters in /vol/httpd/esperto/dev/esperto3/Classes.php on line 65
Is this a bug in CCSb3 or aren't there supposed to be any forms in a header? Why do those classes not get generated when the page is includeable?
And even if I include the from's class code manually I get:
Fatal error: Call to a member function on a non-object in /vol/httpd/esperto/dev/esperto3/Header_events.php on line 38
Line 38 is: $UserInfo->$User->SetValue($name_user);
$User gets declared in the class clsRecordUserInfo I added manually. But other than that it does not get declared or defined which means it's surely no object and thus won't have a method/function SetValue ...
Even changing the page to not includeable doesn't change anything about that .. 
So, I still cannot believe why it is so hard to simply give a lable the name of currently logged in user. But I just can't find a way!
|
|
|
 |
Nicole
|
| Posted: 05/13/2002, 4:11 AM |
|
Hello,
looks like for now you cannot use forms in includable pages.
|
|
|
 |
CodeCharge Support
|
| Posted: 05/13/2002, 5:06 AM |
|
About problem with forms on includable pages. It is problem on our side, it will be solved in next CC Studio release.
|
|
|
 |
schaeff
|
| Posted: 05/13/2002, 10:21 AM |
|
Thanks for your response.
After a weeking of desperately trying in vain at least now I know that I am not a complete idiot...
|
|
|
 |
Jurjen Roels
|
| Posted: 06/11/2002, 1:59 PM |
|
Hi, i have the following custom beforeshow code:
function vote_items_voti1_vote_results_BeforeShow() { //vote_items_voti1_vote_results_BeforeShow @26-E92670CA
//Custom Code @31-2A29BDB7
global $vote_items_voti1;
global $DBjoja;
$TotalVoices=CCDLookUp( "sum(vote_results)", "vote_items", "vote_id=".$vote_items_voti1->ds->Parameters["urlvote_id"] , $DBjoja);
$fldvote_results=$vote_items_voti1->vote_results->GetValue();
if( $TotalVoices != 0 )
{
$Percent=round(($fldvote_results/$TotalVoices)*100,1);
}
else
{
$Percent=0;
}
$fldvote_results="<img src=images/bar.jpg width=" .(int)($Percent)." height=10> " .$Percent. "% (" .$fldvote_results. ")";
$vote_items_votil->vote_results->SetValue($fldvote_results);
When executing this code i get the following error message regarding the last line
Fatal error: Call to a member function on a non-object in C:\Inetpub\Framework\poll_show_result_events.php on line 35
Is this the same problem or am i doing something wrong?
I know that the output from $fldvote_results is the correct HTML text....
|
|
|
 |
Jurjen Roels
|
| Posted: 06/12/2002, 10:33 AM |
|
While pasting the code in the board i saw that i made a typo, which due to my font doesn't really show... the 1 and the l are almost identical..
Jurjen
|
|
|
 |
Yelban
|
| Posted: 09/19/2002, 11:57 PM |
|
Hi! Nicole
I use your sample code in field and I try change to "replace field show value by another table's field"
there are my code
but I don't know "$<form_name>-><field_name>->GetValue()" is correct is correct method or not,
would you please tell me right way? ^_^ and tks.
-----------------------------------------------------------
$dbl = new cls<connection_name>();
global $<form_name>;
if ($<form_name>-><field_name>->GetValue())
{
$replace_name = CCDlookUp("lookup_field", "table_name", "primary_key_field = ". $<form_name>-><field_name>->GetValue(), $dbl);
$<form_name>-><field_name>->SetValue($replace_name);
}
-------------------------------------------------------------
// there is the really working code.
$dbl = new clsDBConnection1();
global $atc_book;
if ($atc_book->media->GetValue())
{
$media_name = CCDlookUp("name", "atc_book_media", "id = ". $atc_book->media->GetValue(), $dbl);
$atc_book->media->SetValue($media_name);
}
|
|
|
 |
|