CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 From - To date selection and default value

Print topic Send  topic

Author Message
songohan

Posts: 89
Posted: 08/19/2009, 11:57 PM

Good day!

I have events table and each event has date. I grid, I'd like to show events based on from - to dates from search. This is no problem, simple where clause does that.
My problem is, that when user comes to page first time, eg. no search input, I'd like to show him events for today and next 6 days.
I tried adding default value for first parameter in where clause "CURRENT_TIMESTAMP + INTERVAL 6 DAYS" but I get error on page "Parse error: syntax error, unexpected T_LNUMBER in...."

Please, how can I do this in CCS...


Thanks,

Andrej
View profile  Send private message
songohan

Posts: 89
Posted: 08/20/2009, 12:42 AM

I mannaged to do this by changing default .php file:

  
$today = date("d.m.Y. H:i:s", mktime(0, 0, 0, date("m"), date("d"),   date("Y"))); 		  
$future = date("d.m.Y. H:i:s", mktime(0, 0, 0, date("m"), date("d")+6,   date("Y")));   
$this->wp->AddParameter("1", "urls_date", ccsDate, $DefaultDateFormat, $this->DateFormat, $this->Parameters["urls_date"], $today, false);           
$this->wp->AddParameter("2", "urls_date1", ccsDate, $DefaultDateFormat, $this->DateFormat, $this->Parameters["urls_date1"], $future, false);

which is ok, but is there a way to do this without changing gray areas in default .php?
View profile  Send private message
melvyn


Posts: 333
Posted: 08/20/2009, 7:04 AM

If you're looking for a place to put your hand-made code, then create an event.
You can try on grid Before Show or Before Select or Before Build Insert, it's up to you.

The correct procedure it's an event.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
songohan

Posts: 89
Posted: 08/20/2009, 7:12 AM

I'm not looking for a place to put custom code.

Could you please read my first post to see what I'm trying to do and suggest how to achieve what I need with event code?

Regards,

Andrej
View profile  Send private message
datadoit
Posted: 08/20/2009, 7:57 AM

songohan wrote:
> Good day!
>
> I have events table and each event has date. I grid, I'd like to show events
> based on from - to dates from search. This is no problem, simple where clause
> does that.
> My problem is, that when user comes to page first time, eg. no search input,
> I'd like to show him events for today and next 6 days.
> I tried adding default value for first parameter in where clause
> "CURRENT_TIMESTAMP + INTERVAL 6 DAYS" but I get error on page "Parse error:
> syntax error, unexpected T_LNUMBER in...."
>
> Please, how can I do this in CCS...
>
>
> Thanks,
>
> Andrej
> ---------------------------------------

Andrej, there's clearly something wrong with your WHERE parameter. If
your SQL doesn't work against the database, then CodeCharge can't help
you either. So for your database, you need to test your condition of:

WHERE YourField = 'CURRENT_TIMESTAMP + INTERVAL 6 DAYS'

to see if that's valid, workable syntax.

If that doesn't work, there's always event code in the grid's
BeforeBuildSelect event (as already suggested by Melvyn). You'll want
to test for the existence of any search parameters, and if there are
none, then you'll default with your own custom WHERE parameter.

See
http://docs.codecharge.com/studio40/html/ProgrammingTec...HEREClause.html

Finally, never EVER adjust CCS's "grey" code. It'll create a WTF!
moment for you later - 100% guaranteed.
songohan

Posts: 89
Posted: 08/20/2009, 8:51 AM

Thank you guys, I moved my code to Before Build Select and now it look like this:

  
$querystring = CCGetQueryString("QueryString", "");  
if (CCGetFromGet("s_date", "-1") == "-1"){  
	$Component->DataSource->Where .= " AND date >= CURRENT_TIMESTAMP and date <=  CURRENT_TIMESTAMP + INTERVAL 6 DAY";  
};  

My further question would be, what is easiest way to determine if some parameter is present in URL?? CCGetFromGet does not really tell me if parameter does not exist or it is simply empty.
All suggestions welcome.
Thanks and best regards,

Andrej
View profile  Send private message
datadoit
Posted: 08/20/2009, 6:12 PM

songohan wrote:
> My further question would be, what is easiest way to determine if some
> parameter is present in URL?? CCGetFromGet does not really tell me if parameter
> does not exist or it is simply empty.
> All suggestions welcome.
> Thanks and best regards,
>
> Andrej
>
> ---------------------------------------

Use PHP's strpos() function.

http://us2.php.net/function.strpos

Add new topic Subscribe to topic   


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.