CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 setting date-field

Print topic Send  topic

Author Message
Tobias Weik
Posted: 01/14/2003, 6:39 AM

CCS 1.07, PHP 4.2, MySQL

hi all,

I am trying to set a value from the db to a date-field in "before show", since
the value is depending on some other values (for example: if a project-id is
set, I want to select the project-startdate from the db and set it as default
for my date-field).

my date-field is formated as "dd.mm.yyyy" (european), the db-format is set to
"yyyy-mm-dd". everything works fine, when I set default = "CurrentDate".

but if I set a before-show event, how do I need to pre-format the fieldvalue?

---
global $myform;

$myform->action_date->SetValue(??);
---

?? is standing for some date, I tried it with both styles (??="yyyy-mm-dd" and
??="dd.mm.yyyy") but my result was always a date-field showing "01.01.0".

thanx for any help
tobias
RonB
Posted: 01/14/2003, 11:25 AM

global $myform;
$myform->action_date->setvalue(Date($myform->action_date->Value,'Y-m-d'));

Ron

"Tobias Weik" <tw@ccug.de> schreef in bericht
news:b017f3$kpn$1@news.codecharge.com...
> CCS 1.07, PHP 4.2, MySQL
>
> hi all,
>
> I am trying to set a value from the db to a date-field in "before show",
since
> the value is depending on some other values (for example: if a project-id
is
> set, I want to select the project-startdate from the db and set it as
default
> for my date-field).
>
> my date-field is formated as "dd.mm.yyyy" (european), the db-format is set
to
> "yyyy-mm-dd". everything works fine, when I set default = "CurrentDate".
>
> but if I set a before-show event, how do I need to pre-format the
fieldvalue?
>
> ---
> global $myform;
>
> $myform->action_date->SetValue(??);
> ---
>
> ?? is standing for some date, I tried it with both styles (??="yyyy-mm-dd"
and
> ??="dd.mm.yyyy") but my result was always a date-field showing "01.01.0".
>
> thanx for any help
> tobias
>

Tobias Weik
Posted: 01/14/2003, 3:38 PM

RonB schrieb:
> global $myform;
> $myform->action_date->setvalue(Date($myform->action_date->Value,'Y-m-d'));
>
> Ron

hi ron,

looks like this isnīt working for me... I tried to modify it for my needs, but
the result is stil the same (displaying a "01.01.0" at my date field). Here is
the full code for the part I used:

---
function evm_prg_seq_program_date_BeforeShow() {
global $evm_prg_seq;
global $DBevm;

$evm_prg_seq->program_date->SetValue(Date(CCDLookUp("date_start","evm_projects","id=".
CCGetFromGet("prj_id",""),$DBevm),'Y-m-d'));

}
---

I want to get a datevalue from the db (yyyy-mm-dd) and put it to the new opened
form as defaultvalue (mm.dd.yyyy), when a project has been selected ("prj_id").

thanks for any help -
tobias
RonB
Posted: 01/15/2003, 5:13 AM

I've been thinking and thinking and then a silly question came to mind....
Why not just add the table you are getting the start date from to the
original query for the grid? . That way no event code is needed. Just join
them on the id fields that link the two tables. Now you can use the format
and DBFormat in the propperties box. Just a thought.

Ron


"Tobias Weik" <tw@ccug.de> schreef in bericht
news:b0271b$jf8$1@news.codecharge.com...
> RonB schrieb:
> > global $myform;
> >
$myform->action_date->setvalue(Date($myform->action_date->Value,'Y-m-d'));
> >
> > Ron
>
> hi ron,
>
> looks like this isnīt working for me... I tried to modify it for my needs,
but
> the result is stil the same (displaying a "01.01.0" at my date field).
Here is
> the full code for the part I used:
>
> ---
> function evm_prg_seq_program_date_BeforeShow() {
> global $evm_prg_seq;
> global $DBevm;
>
>
$evm_prg_seq->program_date->SetValue(Date(CCDLookUp("date_start","evm_projec
ts","id=".
> CCGetFromGet("prj_id",""),$DBevm),'Y-m-d'));
>
> }
> ---
>
> I want to get a datevalue from the db (yyyy-mm-dd) and put it to the new
opened
> form as defaultvalue (mm.dd.yyyy), when a project has been selected
("prj_id").
>
> thanks for any help -
> tobias
>

Tobias Weik
Posted: 01/15/2003, 7:07 PM

RonB schrieb:
> I've been thinking and thinking and then a silly question came to mind....
> Why not just add the table you are getting the start date from to the
> original query for the grid? . That way no event code is needed. Just join
> them on the id fields that link the two tables. Now you can use the format
> and DBFormat in the propperties box. Just a thought.
>
> Ron

hi ron,

well, just like you wrote - "silly question", this would be to easy :))

okay, my fault - looks like I didnt describe my problem good enough, I will try
again:

* I got one table with some project informations like the project-start date
* I got another table where I store my events for the project

when I add a new event, I want to set the project-start date as _default_ for my
event date when opening the insert-form. this field must be editable (and will
be stored to the event-table), since my projects mostly have a duration with
more then one day and the event date can also be some other day then the
project-start date...

since the project-id gets submitted when opening the event insert-form, I want
to use it to get the project-start date for my event date. if no project-id is
set, the event date has the current date as default.

now my problem is to set the date field via custom-code formatted the right way.
the retrieved data from db is "yyyy-mm-dd", the date field is formatted like
"dd.mm.yyyy".

$myform->datefield->SetValue("someday");

always returns bullshit ("01.01.0"), no matter how I format "someday" :(

--

it also looks like I got some generell problems with CCS and date values...

I tried to compare to date fields with

if($myform->date_end->GetValue() <= $myform->date_start->GetValue()) {
$myform->Errors->addError("end may not be smaller then start"); }

but this also shows an error, when for example start is "16.01.2003" and end is
"15.01.2004"?!?

thanx for your time helping me!
tobias

--
my enviroment: CCS 1.07 with PHP and MySQL
Tobias Weik
Posted: 01/15/2003, 9:25 PM

This is a cryptographically signed message in MIME format.

--------------ms090101010304070708020206
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I just solved the problem - it is quite simple, if you know CCS converting every
date/time to unix timestamp and back...

this means: setting the value for a date field as custom code (before show)
needs to have timestamp-format, not the format used in the db ("yyyy-mm-dd") or
the format you want to show ("dd.mm.yyyy")!

If anyone is interested, here is my code for it (look at my last mail for more
details about the situation).

I first check, if the field already has a value (e.g. from db, if it is an
update), then I check, if a project-id is set. If no project-id is set, I set
the current date, else I search the db for the default date to set, depending on
the project-id:

---
global $myform;
global $DBmyconnect;

if(!strlen($myform->program_date->Value) && $myform->program_date->Value !==
false) {
if(!CCGetFromGet("prj_id","") > 0) {
$myform->program_date->SetValue(time());
} else {
$myform->program_date->SetValue(strtotime(
CCDLookUp("date_start","evm_projects","id=".
CCGetFromGet("prj_id",""),$DBmyconnect)));
}
}
---

thanx to RonB for hitting me the right way ;)
tobias

--------------ms090101010304070708020206
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Dis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dI8XKjRiPgDzzV+5V4lRBTl4qjhNaBd
Jv05M76QVvDAl5cg4JU/vvgu1il7nXFHn8pYbiTptdibqXIGOeOUNr/TMgAAAAAAAA==
--------------ms090101010304070708020206--

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright Đ 2003-2004 by UltraApps.com  and YesSoftware, Inc.