Jump to content

ahmedmii

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by ahmedmii

  1. How can I implement it without changing the function?
  2. In some companies they have Monday as a long weekend in some months.
  3. What do you think the best way implement it .So, it can skip the date in table specail ?
  4. To put it simply if the time is getting from table specail it checks the date from this table and compare it to the day this function calcaulate? what I think is gonna work is function hoursLeft($time,$work_starts,$work_ends,$time_to_email,$skip_weekends = true,$skip_long_weekends = true) { if($skip_long_weekends == true) { $day = date('l',strtotime("+ {$day_count} days",strtotime($time))); $result=mysql_query('select `date` from `specialevent`'); while($row=mysql_fetch_array) { $database_date1 = $row["Date"]; if(in_array($day,$database_date1)//This if i can make his compare the timestamp for specailtable with the var $date I think it done $hours+=24; continue; } } }
  5. Hello, I'm new with DW .How can I make the row in the dynamic table hyperlinkes?
  6. This the finall thing I get with it if($skip_long_weekends == true) { //if you want to skip weekends $day = date('l',strtotime("+ {$day_count} days",strtotime($time))); //get the full text of the current day the hours are pointing to. $result10 = mysql_query('SELECT `Date` FROM special'); while($row = mysql_fetch_array($result10)) { $database_date1=$result10["Date"]; if(in_array($day,$database_date1)) { $hours += 24; //add 24 hours to the count. continue; //restart loop, before any counting takes place. } }} The problem is it checks the frist date in the table specail and the rests are ignored even I after I put the while nothing changed
  7. Hello, I'm new with php and I tried to connect with mysql it worked ,but with oracle it didn't who can I connect with oracle ?
  8. Like this function hoursLeft($time,$work_starts,$work_ends,$time_to_email,$skip_weekends = true,$skip_long_weekends = true) { if($skip_long_weekends == true) { $day = date('l',strtotime("+ {$day_count} days",strtotime($time))); $result=mysql_query('select `date` from `specialevent`'); while($row=mysql_fetch_array) { $database_date1 = $row["Date"]; if(in_array($day,$database_date1)//$day==$day in table specialevents skip it $hours+=24; continue; } } }
  9. I hope this explanation is clear.
  10. Well, the user's gonna enter the special date saved in table of special event . for example suppose it's friday 8-12-2011 7:00:00this code will send email on tusday ,but suppose the use enter Monday as a special event it'll skip it like on weekend .So, the email will be sent on Wednesday.
  11. I Apologize for this . This code calculate 24 hours workday .The work starts at 7 and finishes at 16.This code skip the weekend,what I have is another table for special event has dates if it comes across it skiped like the weekend. <?php $database_date = '2011-08-12, 07:00:00'; //this comes from your database, $updated_time = strtotime('+' . hoursLeft($database_date,7,16,24) . ' hours',strtotime($database_date)); //Handle the date: $new_date = date('m-d-Y, H:i:s',$updated_time); //this is when the email should be sent. echo date('m-d-Y, H:i:s',strtotime($database_date)) . '<br />' . $new_date . '<-- you should be emailing at this time!'; //just echo's it to the screen. function hoursLeft($time,$work_starts,$work_ends,$time_to_email,$skip_weekends = true) { //this function handles the count of how many hours you need to fulfill your task. $parts = explode(' ',$time); //split the time off of the date. list($hour, $minute, $second) = explode(':',$parts[1]); //get the hours, minutes, seconds. if($minute == 0) { //if the minutes is over 0, then return a full hour for it $hours = $work_ends - $hour; } else { //otherwise, take into account that this isn't a full hour. $hours = ($work_ends - 1) - $hour; } $day_count = 0; //original day count is 0; for($i = $work_ends,$count = $hours; $count <= $time_to_email; $i++) { //Start the increment at 16, the count at the current hours, keep the count below 25, increment on each loop. if($i > 24) { //if the increment is over 24, reset it to 0. $i = 0; ++$day_count; //increment day_count when i goes over 24 hour limit. if($skip_weekends == true) { //if you want to skip weekends $day = date('l',strtotime("+ {$day_count} days",strtotime($time))); //get the full text of the current day the hours are pointing to. if(in_array($day, array('Saturday','Sunday'))) { //and current day is in the weekend. $hours += 24; //add 24 hours to the count. continue; //restart loop, before any counting takes place. } } } if($i > $work_starts && $i <= $work_ends) { //if the increment is between 7 and 16, add to the count, which will break the loop at 24. $count += 1; } $hours += 1; //add to the hours, the loop breaks at a count of 24, which will give us the total hours to add to the updated_time above. } return $hours; //return hours } ?> OUTPUT: 08-12-2011, 07:00:000 8-16-2011, 14:00:00<-- you should be emailing at this time! 9 hours for Friday: 9 hours for Monday: 7 hours for Tuesday: = 24 hours.
  12. Hello , I've this code its skip the weekend ,and I've a table for special events has field datetime. What I need when its come across this datetime skip it like it does with the weekend. there's the code <?php$database_date = '2011-08-12, 07:00:00'; //this comes from your database, $updated_time = strtotime('+' . hoursLeft($database_date,7,16,24) . ' hours',strtotime($database_date)); //Handle the date:$new_date = date('m-d-Y, H:i:s',$updated_time); //this is when the email should be sent.echo date('m-d-Y, H:i:s',strtotime($database_date)) . '<br />' . $new_date . '<-- you should be emailing at this time!'; //just echo's it to the screen.function hoursLeft($time,$work_starts,$work_ends,$time_to_email,$skip_weekends = true) { //this function handles the count of how many hours you need to fulfill your task. $parts = explode(' ',$time); //split the time off of the date. list($hour, $minute, $second) = explode(':',$parts[1]); //get the hours, minutes, seconds. if($minute == 0) { //if the minutes is over 0, then return a full hour for it $hours = $work_ends - $hour; } else { //otherwise, take into account that this isn't a full hour. $hours = ($work_ends - 1) - $hour; } $day_count = 0; //original day count is 0; for($i = $work_ends,$count = $hours; $count <= $time_to_email; $i++) { //Start the increment at 16, the count at the current hours, keep the count below 25, increment on each loop. if($i > 24) { //if the increment is over 24, reset it to 0. $i = 0; ++$day_count; //increment day_count when i goes over 24 hour limit. if($skip_weekends == true) { //if you want to skip weekends $day = date('l',strtotime("+ {$day_count} days",strtotime($time))); //get the full text of the current day the hours are pointing to. if(in_array($day, array('Saturday','Sunday'))) { //and current day is in the weekend. $hours += 24; //add 24 hours to the count. continue; //restart loop, before any counting takes place. } } } if($i > $work_starts && $i <= $work_ends) { //if the increment is between 7 and 16, add to the count, which will break the loop at 24. $count += 1; } $hours += 1; //add to the hours, the loop breaks at a count of 24, which will give us the total hours to add to the updated_time above. } return $hours; //return hours}?> OUTPUT: 08-12-2011, 07:00:0008-16-2011, 14:00:00<-- you should be emailing at this time!9 hours for Friday:9 hours for Monday:7 hours for Tuesday:= 24 hours. I'm waiting for your replys..
  13. Did you mean like this [attachment deleted by admin]
  14. I did like this ,but still it gave me the same messagge $test=mysql_query('select 'AssignedDate' from 'test'');//this comes from your database, $database_date=$test; and the rest is the same
  15. This what I add to this code. <?php$database_date = mysql_query('select 'AssignedDate' from 'test'')//this comes from your database, updated_time = strtotime('+' . hoursLeft($database_date) . ' hours',strtotime($database_date)); //Handle the date:$new_date = date('m-d-Y, H:i:s',$updated_time); //this is when the email should be sent. [b]line 15[/b] $new_date = date('m-d-Y, H:i:s',$updated_time); //this is when the email should be sent.echo date('m-d-Y, H:i:s',strtotime($database_date)) . '<br />' . $new_date . '<-- you should be emailing at this time!'; //just echo's it to the screen. [b]line 16[/b] function hoursLeft($time) { //this function handles the count of how many hours you need to fulfill your task. ////////Editable variables ///////////////////////////// $work_starts = 7; //start time; $work_ends = 16; //end time; $time_to_email = 24; //amount of time to allow before email goes out, (work hours). ///////End Editable Variables ////////////////////////// $parts = explode(' ',$time); //split the time off of the date. [b]line25[/b] list($hour, $minute, $second) = explode(':',$parts[1]); //get the hours, minutes, seconds. [b]line26[/b] if($minute == 0) { //if the minutes is over 0, then return a full hour for it $hours = $work_ends - $hour; } else { //otherwise, take into account that this isn't a full hour. $hours = ($work_ends - 1) - $hour; } for ($i = $work_ends,$count = $hours; $count <= $time_to_email; $i++) { //Start the increment at 16, the count at the current hours, keep the count below 25, increment on each loop. if($i > 24) { //if the increment is over 24, reset it to 1. $i = 1; } if($i >= $work_starts && $i <= $work_ends) { //if the increment is between 7 and 16, add to the count, which will break the loop at 24. $count += 1; } $hours += 1; //add to the hours, the loop breaks at a count of 24, which will give us the total hours to add to the updated_time above. } return $hours; //return hours } ?> After run the code it gave me this message [attachment deleted by admin]
  16. Hi, about the code when I try to retrive the date from the database like this $database_date=mysql_query('select 'Assigned Date' from 'test'); It gave this message [/img] [attachment deleted by admin]
  17. Thank you such a great gode. I've question is how can it skip the weekend days?
  18. OK, shour=7 ehour=16 the field in database is datetime(2011-07-12 13:22:13) the function that I need is to do is after 24 working hours(three days) from the that time$date send email. CLEAR...... :'( :'(
  19. Come on guys, I really need your help
  20. ahmedmii

    reply

    Come on guys, I really need your help...
  21. Well, I've field datetime so, the work starts at 7 and ends at 16 so,working hours is 9hours .For example value in the field is 2001-01-29 8:00:00 .The fucntion needs to send email after 24 working hours so, like this since the work ends at 16 .It'll be like this 16:00:00-8:00:00 =8:00:00 ,then the first day finish so,increament date++ ,then we see how much hours left 24:00:00-8:00:00=16:00:00 ,then the second day 16:00:00-9:00:00(work day hours)=8:00:00 ,then ,increament date++, then we see how much hours left 16:00:00-8:00:00=8:00:00 ,then the thrid day 9:00:00-8:00:00=one hour the send email. I HOPE IT'S CLEAR NOW. THANK YOU
  22. Hello, I'm new in php and mysql too. The problem is the working hours is 9h starts from 7 to 16 . I need to do is decreament is the time 24h from the time in datetime field and for everydecreamnet increase the date. For example 2011-01-08 13:00:00 when I read it from database I want it like this frist time end time which is 16:00:00 -13:00:00=3 date++. Now 24-3=21 and continue like this how can I implement it?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.