HUGE progress. Thank you, thank you, thank you. You're a wizard. Sorry, I didn't notice all of the instances that needed customization in the code. We're getting the daterange form to come up, the popup calendar in the two fields, and the submit button. Now to tie it all together. I've tried entering some bogus time records but they dont' seem to be coming into the daterange form/invoice part. I can enter dates but the next "screen" shows nada but has two buttons edit and submit (even if I select a date range that I know has hours in it). The date also comes up in a non-US format (16/12/2008) for Dec 16, 2008 - not a big problem just a bit odd looking. Then the "invoice confirmation" form simply says, Invoice CONFIRMATION and has the two buttons - submit and edit. I sort of expected to see some summary of the hours - but perhaps it's blank because it's not finding any info.
The database has this record - Field name Field Data
cf_id : 5
uid : IYjhjNjFkOGI0NDU2
recordtime : 2008-12-17 - 19:34:17
ipaddress : 67.166.247.222
cf_user_id : 0
timeIn :
ts_timein : 19:34:00
timeOut :
ts_timeout : 19:39:00
ts_client : Diecicolori.com
ts_dscr : Testing website
But when I use December 16 to December 18, the invoice confirm and email is blank.
Time sheet for PEASEA for: 16/12/2008 to 18/12/2008
Total time: 00:00:00
Decimal time: 0
Total Cost: $0
Over all Total hours: 00:00:00
Over all Total cost: $0
form code:
<?php
// Check if the form is editable or not
$readonly = "";
$edit = true;
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {
$edit = false;
//$att = true;
$readonly = "readonly='readonly'";
}
?>
<?php if($_POST['date_0']){ ?>
<div class="mainform">
<h3>Invoice CONFIRMATION</h3>
<input type="hidden" id="startdate" name="startdate" value="<?php echo $_POST['date_0'] ?>" />
<input type="hidden" id="enddate" name="enddate" value="<?php echo $_POST['date_1'] ?>" />
<?php
global $mainframe;
$database =& JFactory::getDBO();
$database->setQuery( 'SELECT TIMEDIFF(ts_timeout, ts_timein) as totaltime, TIME_TO_SEC(TIMEDIFF(ts_timeout, ts_timein)) as totalsecs, ts_client, ts_dscr, ts_created
FROM jos_chronoforms_timesheet2
WHERE ts_created BETWEEN "' .$_POST['date_0'].'" AND "'.$_POST['date_1'].'"
ORDER BY ts_client, ts_created');
$database->query();
$records = $database->loadAssocList();
$c=1;
$t=0;
$prevclient = '';
foreach( $records as $row ) {
if($row['ts_client'] != $prevclient){
if($prevclient != '') {
//this is just to add extra rows for filling out the page!
for($w=0; $w < 17 - $t; $w++){
$str .= '
<tr>
<td>Â </td>
<td>Â </td>
<td>Â </td>
<td>Â </td>
</tr>';
}
//get the total time in seconds and convert it to a decimal for each client
$n=$gt/3600;
//close each client table except for the last
$str .= '
<tr style="page-break-inside:avoid;height:.2in">
<td width=414 valign=top style="width:310.5pt;border:none;padding:2.15pt 5.75pt 2.15pt 5.75pt; height:.2in">
<p class=MsoNormal>Â </p>
</td>
<td width=204 colspan=2 style="width:153.0pt;border:none;border-right:solid windowtext 1.0pt; padding:2.15pt .15in 2.15pt .15in;height:.2in">
<p class=RightAligned>TOTAL</p>
</td>
<td width=102 style="width:76.5pt;border-top:none;border-left:none; border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:2.15pt .15in 2.15pt .15in;height:.2in">
<p class=Amount>$'.round($n * 200, 2) .'</p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal>Â </p>
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
<tr style="height:109.9pt">
<td width=720 valign=bottom style="width:7.5in;padding:5.75pt 5.75pt 5.75pt 5.75pt; height:109.9pt">
<p class=MsoNormal>Make all checks payable to My Company LLC</p>
<p class=MsoNormal>Total due in 15 days. Overdue accounts subject to a service charge of 1% per month.</p>
<p class=MsoNormal>Â </p>
</td>
</tr>
<tr style="height:.3in">
<td width=720 style="width:7.5in;padding:0in 5.4pt 0in 5.4pt;height:.3in">
<p class=Thankyou>Thank you for your business!</p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal>Â </p>
</body>
</html> '."\n";
fwrite($fp, $str);
fclose($fp);
//set these back to 0 so that the total does not include the previous clients
$n=0;
$gt = 0;
$t=0;
$fp='';
$str='';
}
// start the new WORD document
$cname = str_replace(".","-",$row['ts_client']);
$filename = 'invoices/'.$cname.'-invoice_'.date('m-d-Y').'.doc';
$fp = fopen($filename, 'x+');
//start writting the file contents.
//throw in some style
$str = '
<html>
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
line-height:110%;
font-size:8.5pt;
font-family:Tahoma;
letter-spacing:.2pt;}
h1
{margin:0in;
margin-bottom:.0001pt;
text-align:right;
line-height:110%;
font-size:20.0pt;
font-family:Tahoma;
color:gray;
letter-spacing:.2pt;}
h2
{margin:0in;
margin-bottom:.0001pt;
line-height:110%;
font-size:8.0pt;
font-family:Tahoma;
text-transform:uppercase;
letter-spacing:.2pt;}
h3
{margin:0in;
margin-bottom:.0001pt;
line-height:110%;
font-size:8.5pt;
font-family:Tahoma;
letter-spacing:.2pt;
font-weight:normal;
font-style:italic;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{margin:0in;
margin-bottom:.0001pt;
line-height:110%;
font-size:8.0pt;
font-family:Tahoma;
letter-spacing:.2pt;}
p.Companyname, li.Companyname, div.Companyname
{margin-top:7.0pt;
margin-right:0in;
margin-bottom:0in;
margin-left:0in;
margin-bottom:.0001pt;
line-height:110%;
font-size:12.0pt;
font-family:Tahoma;
letter-spacing:.2pt;
font-weight:bold;}
p.Columnheading, li.Columnheading, div.Columnheading
{margin:0in;
margin-bottom:.0001pt;
text-align:center;
line-height:110%;
font-size:8.0pt;
font-family:Tahoma;
letter-spacing:.2pt;
font-weight:bold;}
p.RightAligned, li.RightAligned, div.RightAligned
{margin:0in;
margin-bottom:.0001pt;
text-align:right;
line-height:110%;
font-size:8.0pt;
font-family:Tahoma;
text-transform:uppercase;
letter-spacing:.2pt;}
p.Thankyou, li.Thankyou, div.Thankyou
{margin:0in;
margin-bottom:.0001pt;
text-align:center;
line-height:110%;
font-size:10.0pt;
font-family:Tahoma;
letter-spacing:.2pt;
font-weight:bold;}
p.Amount, li.Amount, div.Amount
{margin:0in;
margin-bottom:.0001pt;
text-align:right;
line-height:110%;
font-size:8.5pt;
font-family:Tahoma;
letter-spacing:.2pt;}
@page Section1
{size:8.5in 11.0in;
margin:.5in .5in 36.7pt .5in;}
div.Section1
{page:Section1;}
/* List Definitions */
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
<body>
'."\n";
$strc=$row['ts_client'];
$fl=$strc[0];
//begin actual page
$str .= '
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
<tr style="height:39.75pt">
<td width=361 rowspan=2 valign=top style="width:270.6pt;padding:0in 5.4pt 0in 5.4pt; height:39.75pt">
<p class=Companyname>My Company LLC</p>
<h3>Web work</h3>
<p class=MsoNormal>Â </p>
<p class=MsoNormal>1000 Pennsylvania Court</p>
<p class=MsoNormal>Martindale, TX 45332</p>
<p class=MsoNormal>Phone (356)808-0376 </p>
</td>
<td width=359 valign=top style="width:269.4pt;padding:0in 5.4pt 0in 5.4pt; height:39.75pt">
<h1>INVOICE</h1>
</td>
</tr>
<tr style="height:39.75pt">
<td width=359 valign=bottom style="width:269.4pt;padding:0in 5.4pt 0in 5.4pt; height:39.75pt">
<p class=RightAligned>Invoice #'.$c.'</p>
<p class=RightAligned>Date: '.date('F jS, Y').'</p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal>Â </p>
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
<tr style="height:1.0in">
<td width=360 valign=top style="width:3.75in;padding:0in 5.4pt 0in 5.4pt; height:1.0in">
<h2>To:</h2>
<p class=MsoNormal>PeaSea</p>
<p class=MsoNormal>My Company LLC</p>
<p class=MsoNormal>1000 Pennsylvania Court</p>
<p class=MsoNormal>Martindale, TX 45332</p>
<p class=MsoNormal></p>
</td>
<td width=360 valign=top style="width:3.75in;padding:0in 5.4pt 0in 5.4pt; height:1.0in">
<h2>For:</h2>
<p class=MsoNormal>'.$row['ts_client'].'</p>
<p class=MsoNormal>#'.$fl.date('mdy').rand(31,69).'</p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal>Â </p>
<p class=MsoNormal>Â </p>';
$str .= '
<div align=center>
<table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse;border:none">
<tr height=20 class="headrow">
<td width="66%"><p class=Columnheading>Description:</p></td>
<td width="12%"><p class=Columnheading>Hours:</p></td>
<td width="12%"><p class=Columnheading>Rate:</p></td>
<td width="12%"><p class=Columnheading>Amount:</p></td>
</tr>';
$prevclient = $row['ts_client'];
}
$ts=$row['totalsecs']/3600;
$str .= '
<tr>
<td><p class=MsoNormal>'.$row['ts_dscr'].'</p></td>
<td><p class=MsoNormal>'.round($ts,2) .'</p></td>
<td><p class=Amount>$200</p></td>
<td><p class=Amount>'.round($ts * 200, 2) .'</p></td>
</tr>';
$gt += $row['totalsecs'];
$gtt += $row['totalsecs'];
$c++;
$t++;
}
for($w=0; $w < 17 - $t; $w++){
$str .= '
<tr>
<td>Â </td>
<td>Â </td>
<td>Â </td>
<td>Â </td>
</tr>';
}
$n=$gt/3600;
$str .= '
<tr style="page-break-inside:avoid;height:.2in">
<td width=414 valign=top style="width:310.5pt;border:none;padding:2.15pt 5.75pt 2.15pt 5.75pt; height:.2in">
<p class=MsoNormal>Â </p>
</td>
<td width=204 colspan=2 style="width:153.0pt;border:none;border-right:solid windowtext 1.0pt; padding:2.15pt .15in 2.15pt .15in;height:.2in">
<p class=RightAligned>TOTAL</p>
</td>
<td width=102 style="width:76.5pt;border-top:none;border-left:none; border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:2.15pt .15in 2.15pt .15in;height:.2in">
<p class=Amount>$'.round($n * 200, 2) .'</p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal>Â </p>
<div align=center>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
<tr style="height:109.9pt">
<td width=720 valign=bottom style="width:7.5in;padding:5.75pt 5.75pt 5.75pt 5.75pt; height:109.9pt">
<p class=MsoNormal>Make all checks payable to My Company LLC</p>
<p class=MsoNormal>Total due in 15 days. Overdue accounts subject to a service charge of 1% per month.</p>
<p class=MsoNormal>Â </p>
</td>
</tr>
<tr style="height:.3in">
<td width=720 style="width:7.5in;padding:0in 5.4pt 0in 5.4pt;height:.3in">
<p class=Thankyou>Thank you for your business!</p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal>Â </p>
</body>
</html> '."\n";
fwrite($fp, $str);
fclose($fp);
?>
</div>
<?php } ?>
<?php
if ( $edit ) { ?>
<h3>Invoice FORM</h3>
<div class="form_item">
<div class="form_element cf_datetimepicker">
<label class="cf_label">Start Time:</label>
<input onclick="new Calendar(this);" class="cf_datetime" size="20" id="date_0" name="date_0" type="text">
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_datetimepicker">
<label class="cf_label">End Time:</label>
<input onclick="new Calendar(this);" class="cf_datetime" size="20" id="date_1" name="date_1" type="text">
</div>
<div class="clear">Â </div>
</div>
<?php } ?>
<?php
$f=1;
$fdate = 'invoices/*-invoice_'.date('m-d-Y').'.doc';
//echo $fdate;
foreach (glob("$fdate") as $filename) {
echo '<input type="hidden" id="att'.$f.'" name="att'.$f.'" value="'.$filename.'"> '. "\n";
$f++;
}
?>
<div class="form_item">
<?php
if ( $edit ) {
?>
<div class="form_element cf_button">
<input value="Submit" name="submit" type="submit">Â
<input value="Reset" type="reset">
</div>
<?php
} else {
?>
<div class="form_element cf_button">
<input type="submit" name="submit" value="Send">Â
<input type="submit" name="submit" value="Edit">
</div>
<?php
}?>
<div class="clear">Â </div>
</div>