CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Background Color on Day Of week On Calendar

Print topic Send  topic

Author Message
mbishop1980

Posts: 31
Posted: 06/24/2008, 5:01 PM

Scenario
I'm working on an Intranet where users will use a calendar to select a day to submit an order. They are only allowed to submit orders on Thursday. During the week they can add and remove items from the order, but it will all go on that Thursday's order.

Desired Effect
What I'm wanting to do is based on whether or not the user has submitted the order, whether it is in progress or submitted. I want to show this by using a color background. If the user hasn't submitted the order the background would be red, if it is in progress: blue and the order was submitted: green.

Problem
I can color the background of everyday but not one day or every Thursday.
I am using the following post to help with no avail.
http://forums.codecharge.com/posts.php?post_id=97602

Plea
Can someone please give me some advise on how this can be done.
_________________
Thanks,
Eric
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/24/2008, 6:57 PM

I can help you color the background, like described in the post you refer to correctly.
However I need to understand what exactly you are doing.
Could you place a link to a demo or post link to screen shots showing me the flow of things.
My problem with your description of your callenge is, that from the text, I cannot deduct what is in the calendar event, how it is put there and how to determine (what field has what value) the status of an order.

Try and explain in more detail what and how, then I will read up on that in the morning and see if I can help you on your way during the day.

Walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mbishop1980

Posts: 31
Posted: 06/26/2008, 6:21 AM

Thank you Walter
I don't have a public place where I can link a screenshot, but I will put the code down below.
The Calendar is going to show whether or not an order has been placed for the particular Thursday.
I would make it so if they haven't placed an order then they can click on the day and it will take them to an Editable Grid.
If they have placed an order but haven't submitted it than they would click the same link and go to the same Editable Grid.

I have set up the Editable Grid page to read from session variables to determine whether or not and order has been placed by this person for this Thursday. That part I have done. If they have it will pull the information.
If they haven't than it will create a record that Calendar will pull off of.
There is a status field that holds a value which will determine which color the the background has.
just want to be able to color code and allow them to see right off the bat whether or not they have submitted an order.

I hope this makes sense, the part I'm working on right now is just to get Thursday to have the background color. With the code below the whole calendar has a green background to which I don't want.

I hope this makes sense, if not please let me know and I will try again.

<?php
//BindEvents Method @1-2B970F4B
function BindEvents()
{
global $shopping_carts;
$shopping_carts->CCSEvents["BeforeShowDay"] = "shopping_carts_BeforeShowDay";
}
//End BindEvents Method

//DEL // -------------------------
//DEL $day = 'Thursday';
//DEL if (CCDayofweek($day)) {
//DEL $Container->Attributes->SetValue('backcolor', 'style="background-color: green;"');
//DEL }
//DEL // -------------------------

//shopping_carts_BeforeShowDay @2-9DCFF4FB
function shopping_carts_BeforeShowDay(& $sender)
{
$shopping_carts_BeforeShowDay = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $shopping_carts; //Compatibility
//End shopping_carts_BeforeShowDay

//Custom Code @23-2A29BDB7
// -------------------------
$day = "Thursday";
if (CCDayOfWeek($day)) {
$Component->Attributes->SetValue('backcolor','style="background-color: green;"'); }

// -------------------------
//End Custom Code

//Close shopping_carts_BeforeShowDay @2-CA9A0C1D
return $shopping_carts_BeforeShowDay;
}
//End Close shopping_carts_BeforeShowDay


?>
_________________
Thanks,
Eric
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/26/2008, 8:48 AM

    
  
$day = "Thursday";   
if (CCDayOfWeek($day)) { 	  
    $Component->Attributes->SetValue('backcolor','style="background-color: green;"'); 	  
} else {  
   $Component->Attributes->SetValue('backcolor',''); // reset the attribute or set any other color  
}  
// -------------------------  
//End Custom   
i edited part of your code.
An Else has been added, resetting the arrtibute .

that should do it.
Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/26/2008, 8:55 AM

Show me the html where you added the attribute.your attribute can also be in wrong place.
Normally we colour the event

walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mbishop1980

Posts: 31
Posted: 06/26/2008, 11:07 AM

The code is below.

<!-- BEGIN Day -->
<td {Style}{shopping_carts:backcolor}>{DayNumber}</td><!-- END Day -->

_________________
Thanks,
Eric
View profile  Send private message
mbishop1980

Posts: 31
Posted: 06/26/2008, 11:14 AM

I tried it and it still colors the whole calendar. I know I am doing something wrong. when you say color event are you talking about the beforeshow day event?

_________________
Thanks,
Eric
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/26/2008, 11:43 AM

My dear friend,
you have just cost me a lot of time........
Where did you get your code from??

This is the one code that will color the thursdays green, assuming your week is set to start on Sunday.
  
$day = 5; // Thursday if weekstart = Sunday, see Project Settings   
if (CCDayOfWeek($Container->CurrentProcessingDate) == $day) {   
   $Component->Attributes->SetValue('backcolor','style="background-color: green;"'); }  

EXTRA:
This will show you the Dayname in text
  
echo ("1:" . CCFormatDate($Container->CurrentProcessingDate,array("dddd")) );  

Your function, which is in Common.php, expects a valid date (array), and will then return the index = number of the day in the week.
  
echo ("2:" . CCDayOfWeek($Container->CurrentProcessingDate) );  

The problem with your codeblock was not in the attribute setting
It was in the test
  
$day = "Thursday";   
if (CCDayOfWeek($day)) { ..........  
a: CCDayOfWeek returns integer index.
b: $day is set to a string value
c: you use the function on your $date, and not on the variable used in the BeforeShowDay Event.

So now you know how to, have fun with it.

Walter





_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mbishop1980

Posts: 31
Posted: 06/26/2008, 1:34 PM

Thank you very much Walter
I will change the status to Resolved
_________________
Thanks,
Eric
View profile  Send private message
mbishop1980

Posts: 31
Posted: 06/26/2008, 1:34 PM

Thank you very much Walter
I will change the status to Resolved
_________________
Thanks,
Eric
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/26/2008, 3:15 PM

Your welcome

http://donate.consultair.eu

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

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.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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