jcarlee68
Posts: 7
|
Posted: 07/07/2011, 3:39 PM |
|
Hi everyone!
I'm new in CodeChargeStudio and I've learn a lot of tricks here in the forums.
Now I have a problem that it may be easy for you all:
I made a mySqL database to controls the use of stencils in some printing machines to assure that the operator clean it before send them to the line and they never deliver a stencil without calibration. The calibartion is made every week.
The table has several columns but the most important are:
StencilID | Location | CalibrationDate |
I created a link in StencilID to control the Location where this stencil will be sent (in wich line) and when this stencil returned. When the operator select the StencilID that he needs, the link send it to another page where he selects the location where to send it to.
Right now, the operator has to check the date for calibration before click on the link (totally Operator dependand operation )
What I need is to somehow avoid the opcion to send the stencil if is out of calibration date.
Some ideas I have would be:
a) In BeforeShow, create a condition where the CalibrationDate is compared with TodayDate.
If the Stencil is out of calibration, the link will be changed to another page (calibrationPage);otherwise, it is sent to LocationPage. Remember that the link is in StencilID....
b) In BeforeShow, same comparison but instead of create another link, simply eliminate the link and just show the StencilID. The oprator will not going to have the option and it has to calibrate before send it
Any help will be very appreciated.
Saludos!
JC
|
|
|
jjrjr2
Posts: 131
|
Posted: 07/07/2011, 5:07 PM |
|
Hi
Here is a method to do your date comparison. Remember MySql stores DATETIME fields basically as text fields (Unless your are storing your dates as timestamps). So generally the date will be in your database something like "YYYY-MM-DD HH:MM:SS"
Since it is difficult to compare this type date (unless exact match) you might need to convert it to a TIMESTAMP type value where you can do compares such as < or >.
This can be done by running your database value thru a function like this..
/*
* Function to turn a mysql datetime (YYYY-MM-DD HH:MM:SS) into a unix timestamp
* @param str
* The string to be formatted
*/
function convert_datetime($str) {
list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
return $timestamp;
}
So now in your Before Show Event you could do something like this...
$CalibrationTimeStamp = convert_datetime($Container->YourDataBaseDateControl->GetValue());
Then compare that value to todays date like so
$TodayTimeStamp=time();
if($TodayTimeStamp=>$CalibrationTimeStamp){
Do whatever U wanna do. Redirect Link, Hide/show components/panels... etc.
}
Hope that helps U get started.
John
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us |
|
|
jcarlee68
Posts: 7
|
Posted: 07/09/2011, 9:14 PM |
|
Hi John
It seems that I did something wrong...Let me tell you what I did
1.- I added the function you posted in the Common.php
2.- I add another label StencilIDLab in addition to the StencilID link (to hide/show only the one that has the link if the comparison is false). Remember that NextCal is the MySQL database control in the Table
3.- in the BeforeShow event for the StencilID link, I added the following Code:
global $SalidaStenciles;
$NextCalVal= $SalidaStenciles->NextCal->GetValue();
$CalibrationTimeStamp = convert_datetime($NextCalVal);
$TodayTimeStamp=time();
if($TodayTimeStamp > $CalibrationTimeStamp){
$SalidaStenciles->StencilID->Visible=False;
$SalidaStenciles->StencilIDLab->Visible=True;
} else {
$SalidaStenciles->StencilID->Visible = True;
$SalidaStenciles->StencilIDLab->Visible = False;
}
I have an error that says:
Warning: mktime() expects parameter 1 to be long, string given in C:\WebDocs\StencilsDatabase\Common.php on line 140
I tried to echo $NextCalVal but only returned the word Array
The $TodayTimeStamp returned 1310260540 (for today's date)
Any idea?
I appreciate a lot your help!
JC
Any idea?
I appreciate a lot your help!
JC
|
|
|
bannedone
Posts: 273
|
Posted: 07/10/2011, 1:01 AM |
|
Hi
I have been banned in this forum By Yes for telling the truth & agreeing with another associate here in this forum.
I will not be back here since Yes choses to censor the truth and opinions on the only people who contribute value here.
I did not want to leave you in a lurch so I temprorarily craeted this user ID so I could get back to you.
Now for your problem with date try this
Instead of:
$NextCalVal= $SalidaStenciles->NextCal->GetValue();
Try:
$NextCalVal= $SalidaStenciles->NextCal->GetText();
Let me know if that works.
Hope that helps
John
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
bannedone
Posts: 273
|
Posted: 07/10/2011, 1:03 AM |
|
LOL
I just found out that YES has even banned posting the name of the web site I created to support them.
What a bunch of goofs..
I just don't get it..
I will not be back on this forum
LOL
Anymore CCSEl*** is now a dirty word here. I know that makes some folks happy... JCC... Who also is prolly gone and not using CCS any more...
If that did not help you. Post on my CCS support site in my signature block on my earlier post for you.
Yikes
John
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
datadoit
|
Posted: 07/10/2011, 6:15 AM |
|
On 7/7/2011 6:39 PM, jcarlee68 wrote:
> Some ideas I have would be:
> a) In BeforeShow, create a condition where the CalibrationDate is compared with
> TodayDate.
> If the Stencil is out of calibration, the link will be changed to another page
> (calibrationPage);otherwise, it is sent to LocationPage. Remember that the link
> is in StencilID....
Link control's BeforeShow event Custom Code:
if (strtotime(date('Y-m-d', $Component->GetValue())) <=
strtotime(date('Y-m-d')) ) {
$Component->SetLink("calibrationPage.php?" .
CCGetQueryString("QueryString", ""));
}
> b) In BeforeShow, same comparison but instead of create
another link,
> simply eliminate the link and just show the StencilID. The oprator
will not
> going to have the option and it has to calibrate before send it
Create a new label StencilIDLabel and place it to the right of your
StencilIDLink control. Link control's BeforeShow event add Custom Code:
global $StencilIDLabel;
if (strtotime(date('Y-m-d', $Component->GetValue())) <=
strtotime(date('Y-m-d')) ) {
$Component->Visible = false;
$Container->StencilIDLabel->Visible = true;
}
else {
$Component->Visible = true;
$Container->StencilIDLabel->Visible = false;
}
|
|
|
bannedone
Posts: 273
|
Posted: 07/10/2011, 11:42 AM |
|
Hi again
The code above that datadoit posted will not work either just like the code I posted for you will not.
I just remembered this post I made years ago regarding dates.. (LOL I forgot this, as it has been a long time since I played with dates like this)
/posts.php?post_id=97052
(It seems YES has removed the capability to post full URLs. So the above points to a post it in this forum. Use the full form URL and add this to get to the post).
Also , as I posted there, the array returned for a CCS date type control contains the the timestamp in dimension [0]
So that routine I originally posted is uneccessary a well as the routine Data posted.
$NextCalVal[0] contains your database cal dates timestamp.
So your code could look like this
global $SalidaStenciles;
$NextCalVal= $SalidaStenciles->NextCal->GetValue();
$CalibrationTimeStamp = $NextCalVal[0]; ///This puts the calibration timestamp into your variable
$TodayTimeStamp=time();
if($TodayTimeStamp > $CalibrationTimeStamp){
$SalidaStenciles->StencilID->Visible=False;
$SalidaStenciles->StencilIDLab->Visible=True;
} else {
$SalidaStenciles->StencilID->Visible = True;
$SalidaStenciles->StencilIDLab->Visible = False;
}
It seems YES has dissallowed posting of URLS in the forum.
The partial link above with using the full forum URL preceding is how to see the post.
LOL. Datadoit. Wonder why U were not banned?? It was your post I just agreed with that got me banned...
LOL U notice they deleted both our posts regarding the use using CCS for that guys accounting project,,.
What a deal...
Bye
John
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
jcarlee68
Posts: 7
|
Posted: 07/11/2011, 6:28 AM |
|
John
With your previous suggestion,$NextCalVal= $SalidaStenciles->NextCal->GetText(); the code worked but with a little change:
When I echo the $NextCalVal, it returned me July 10, 2011...Obviously the function did not have the correct format and gave me a different timestamp...So what I did is to format the $NextCal with the MySQL format, (MY mistaque is that $NextCal is a label, connected with the Calibration date in the MySQL database.... LOL). So instead of change everything, I just change this label to hidden with the DB format and created another label with the date format that I had and !ZAZ! everything worked....
I really appreciate a lot your support!!! It's a shame that they banned you. you are a great person...
You have a new fan in the CCSEl*** (oops!)
Saludos!
JC
|
|
|
|