jakebur01
Members-
Posts
885 -
Joined
-
Last visited
Everything posted by jakebur01
-
Is this the correct way to use IS NOT in an if statement? if($today<>"$projected") { }
-
Using just the sharename worked! Thanks.
-
hmm.. I tried mapping a drive under M:\ pointing it to the sharename, but I got the same error. Warning: fopen(M:\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69 $filename = "M:\\resource.pdf";
-
Is there a way to write a file to a directory on my network? I tried creating a shortcut called automated and pointed it to the network path. I also set up a virtual directory called automated in IIS and still could not make it work. I gave it read and write permissions. error Warning: fopen(C:\Inetpub\wwwroot\dompdf\automated\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69 Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 70 Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 71 code require_once("dompdf/dompdf_config.inc.php"); $html = '<html><body>'. '<p>Put your html here, or generate it with your favourite '. 'templating system.</p>'. '</body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $pdfoutput = $dompdf->output(); $filename = "C:\\Inetpub\\wwwroot\\dompdf\\automated\\resource.pdf"; $fp = fopen($filename, "a"); fwrite($fp, $pdfoutput); fclose($fp);
-
PHP Version 5.3.6 Windows NT WAVELINK 5.1 build 2600 (Windows XP Professional Service Pack 3) i586 Mar 17 2011 10:46:06 code $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday'))); $saturday = date('Y-m-d', strtotime('last Saturday')); $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month')))); $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))); $thisfirstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month')))); $thislastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))); if($firstday<=$sunday && $sunday<=$lastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); echo"1<br />$month|$year"; } elseif($firstday<=$saturday && $saturday<=$lastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); echo"2<br />$month|$year"; } elseif($thisfirstday<=$sunday && $sunday<=$thislastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); echo"3<br />$month|$year"; } elseif($thisfirstday<=$saturday && $saturday<=$thislastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); echo"4<br />$month|$year"; } else { $month="00"; $year="0000"; }echo "<hr />Firstday: $firstday<br>\n"; // Firstday: 1969-12-28 echo "Sunday: $sunday<br>\n"; // Sunday: 2011-10-02 echo "Lastday: $lastday<br>\n"; // Lastday: 1969-12-27 output 3 10|2011 Firstday: 2011-08-28 Sunday: 2011-10-02 Lastday: 2011-10-01
-
This is what I get: Firstday: 2011-08-28 Sunday: 2011-10-02 Lastday: 2011-10-01
-
PHP Version 5.3.6
-
I did echo them out, and it works. There is no problem now as far as I know. I just wanted a second eye on the code. Basically, what ever day the last Friday of the month lands on... the Saturday following will make up the last day of the months period. I am running a scheduled task ever Thursday morning. I am using this code to determine which month period the previous week falls into.
-
That is exactly what i'm trying to do! Does this code look ok for finding that out? $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday'))); $saturday = date('Y-m-d', strtotime('last Saturday')); $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month')))); $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))); $thisfirstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month')))); $thislastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))); if($firstday<=$sunday && $sunday<=$lastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); } elseif($firstday<=$saturday && $saturday<=$lastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); } elseif($thisfirstday<=$sunday && $sunday<=$thislastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); } elseif($thisfirstday<=$saturday && $saturday<=$thislastday) { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); } else { $month="00"; $year="0000"; }
-
Ok... I was being careless. So, do I still need to use a timestamp rather than a formatted date?
-
This didn't work either: <?PHP $today = strtotime("now"); $sunday = strtotime('last Sunday', strtotime('last Saturday')); $saturday = strtotime('last Saturday'); $firstday = strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month'))); $lastday = strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))); $thisfirstday = strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month'))); $thislastday = strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))); echo"$today<hr />$firstday<br />$lastday<hr />$thisfirstday<br />$thislastday"; if($firstday>="$today" && $lastday<="$today") { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); echo"1<br />$month|$year"; } elseif($thisfirstday>="$today" && $thislastday<="$today") { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); echo"3<br />$month|$year"; } ?>
-
OMG... That explains why some of my other scripts are not working correctly. I'm glad I was playing with this so I could learn that.
-
Todays date is between the criteria in if else, but it is not catching it. <?PHP $today = date('Y-m-d'); $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday'))); $saturday = date('Y-m-d', strtotime('last Saturday')); $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month')))); $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))); $thisfirstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month')))); $thislastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))); echo"$today<hr />$firstday<br />$lastday<hr />$thisfirstday<br />$thislastday"; if($firstday>="$today" && $lastday<="$today") { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))))); echo"1<br />$month|$year"; } elseif($thisfirstday>="$today" && $thislastday<="$today") { $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))))); echo"3<br />$month|$year"; } ?> output: 2011-10-10<hr />2011-08-28<br />2011-10-01<hr />2011-10-02<br />2011-10-29
-
I would like to store weekly reports into documents. I am familiar with storing data to a regular text document, but it does not keep bold text, tables and so forth. Are there any other documents that would not be to hard to output to such as .pdf, .rtf, .doc, etc.? I've attached the current format we are using in excel. Now that I have things automated in php, I would like to output to a document with almost identical formatting. And how can I keep it on 8 1/2" x 11" pages without it splitting data or tables between two pages? Thanks, Jake
-
Thank you for your help. Those were the correct dates.
-
Cool. How reliable is strtotime? How does this code look? It seems to work well. If you see something I should alter, please let me know. $sunday=date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday', strtotime('now')))); $saturday=date('Y-m-d', strtotime('last Saturday', strtotime('now'))); $firstday=date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month')))); $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))); echo"$sunday<br />$saturday<hr />"; echo"$firstday<br />$lastday";
-
Sorry... Yes, thank you. I guess I got so caught up in trying to find out the last friday of the previous month that I forgot what my original question was. Should that code find the previous Sunday - Saturday no matter what week you are in?
-
I ran your code and got these two dates: 2011-08-28 2011-09-03
-
If I could find the last Friday of the previous month and add one.... this would give me my ending period date. And I found the last Friday for the month before last and add two... this would give me my Starting period date.
-
Ok... This may help. I just learned this. Our company uses 4-week and 5-week periods. The last friday of the month makes up the last week of the month. No, I have not run it yet. I wasn't sure if you understood what I was trying to do or not.
-
Let me be more specific. Look at the table. table Id Saturday Sunday 0 2011-07-31 2011-08-06 1 2011-08-07 2011-08-13 2 2011-08-14 2011-08-20 3 2011-08-21 2011-08-27 4 2011-08-28 2011-09-03 5 2011-09-04 2011-09-10 6 2011-09-11 2011-09-17 7 2011-09-18 2011-09-24 8 2011-09-25 2011-10-01 9 2011-10-02 2011-10-08 If the current date is 2011-10-07, how could I use php to query the table for last months periods (which are Sat. 8/28 - Sun. 10/01)? How can I get php to know how my week periods are setup? I could set up a separate table and store the period range for each month, but I would rather have the whole thing do it automatically if I could. Take a look at how our periods are set up below. It will help if you look on a calendar to see what I am talking about. Jan. 1/2-1/29 Feb. 1/30-2/26 Mar. 2/27-3/26 Apr. 3/27-4/30 May 5/1-5/28 Jun. 5/29-6/25 July 6/26-7/30 Aug. 7/31-8/27 Sept. 8/28-10/1 Thanks.
-
The problem is I don't know how to retrieve the info above. I have the dates, but I don't know how to retrieve it. It is not going to have a html form field to select date periods. I want it to automatically select the previous months weeks. So, like today if I run the script I want it to know to retrieve the previous month which is September and know what dates to select in september.... which would be 08/28 - 09/03.
-
Sample Structure: Id (int 11), Sunday (date), Saturday (date) Sample Data: 0 2011-08-28 2011-09-03 1 2011-09-04 2011-09-10 Let say as an example the table above is filled with every week this year. How could I query it for any month of the year. If I wanted to query it for April 2011, how could I do that and it contain all the weeks that fall within that month? Every Sunday - Saturday period within any month I pick. I can find the previous Sunday, that as not a big of a concern as being able to do this. ___________________________ If it would be hard to query the sample table. I could store the data a different way maybe? Calculate what month the previous week is in before I store it and use a table like this: Id, Month, Year, Sunday, Saturday 0 04 2011 2011-08-28 2011-09-03
-
I need to do some reporting and I need some help. The reporting periods are as follows: 08/28-09/03 09/04-09/10 09/11-09/17 09/18-09/24 09/25-10/01 So, they are Sunday through Saturday throughout each month. Say the date is Sept. 7.... How can I find out the date of the Sunday before last. How can I know what month I am reporting for? I am querying the database each Wed. for sales data from the previous month. I want to take the totals from my query and store them in a separate table. The problem is, I don't know how to find out what month the previous week falls into. And I don't know how to find the date of the Sunday before last. Thanks, Jake