echo '</span></div></td>'; echo '<td align="right"><div style="width:100px;">' . number_format($listCustomer[$customer['cus_id']]['pay'], 2) . '</div></td>'; echo '<td align="right"><div style="width:100px;word-wrap:break-word;">' . number_format($listCustomer[$customer['cus_id']]['charge'], 2) . '</div></td>'; echo '<td align="right"><div style="width:100px;">' . number_format($listCustomer[$customer['cus_id']]['total'], 2) . '</div></td>'; echo '</tr></table></a>'; } foreach ($database->Select('contract', array('cus_id' => $customer['cus_id']), 0) as $contract) { $object = $database->Value('object_rental', array('object_id' => $contract['object_id']), 0); $objectType = $database->Value('object_type', array('type_id' => $object['type_id']), 0); foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'paid' => 0), 0) as $payment) { echo '<a href="?pay=money&id=' . $payment['pay_id'] . '">'; echo '<table align="left" width="100%" border="0" cellspacing="0" cellpadding="3" class="list-drop" style="background-color:#EEE;">'; echo '<tr style="height:20px" class="list-drop">'; echo '<td align="center"><div style="width:25px;" id="img_' . $payment['pay_id'] . '"> </div></td>'; echo '<td align="center"><div style="width:35px;" id="id' . $payment['pay_id'] . '"></div></td>'; echo '<td align="left"><div style="width:270px;word-wrap:break-word;">' . $objectType['type_name'] . $object['detail'] . ' (' . ThaiDate::Full($payment['pay_date']) . ')</div></td>'; echo '<td align="right"><div style="width:100px;">' . number_format($payment['amount'], 2) . '</div></td>'; echo '<td align="right"><div style="width:100px;word-wrap:break-word;">' . number_format($payment['charge'], 2) . '</div></td>'; echo '<td align="right"><div style="width:100px;">' . number_format($payment['amount'] + $payment['charge'], 2) . '</div></td>'; echo '</tr></table></a>'; } } if ($listCustomer[$customer['cus_id']]['total'] != 0) { $colorRow++; } } if ($database->Count('payment', array('paid' => 0), 0) == 0) { echo '<table align="right" width="100%" border="0" cellspacing="0" cellpadding="3" id="list-user"><tr style="height:30px"><td align="center" align="center" colspan="8">'; echo '<strong>' . _REGISTER_NONE . '</strong>'; echo '</td></tr></table>'; }
} elseif ($DayLoop < $firstDay) { $oldMonthLimit++; $tmpString .= '<td><input id="unDay" type="button" value="' . $oldMonthLimit . '" /></td>'; } else { $tmpString .= '<td><input id="unDay" type="button" value="' . $DayNext . '" /></td>'; $DayNext++; } if ($DayLoop > $limitDay) { $iRowStop = false; } } $tmpString .= '</tr>'; } $tmpString .= '</tbody></table>'; echo json_encode(array('list' => $tmpString, 'mName' => $nameMonth[$isToday['mon']] . ' ' . ($isToday['year'] + 543), 'date' => ThaiDate::Full(ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year'])), 'stamp' => ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year']), 'exdate' => ThaiDate::Full(ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year'] + 1)), 'exstamp' => ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year'] + 1))); } elseif ($_POST['get'] == 'month') { $miniMonth = array(1 => _JA, 2 => _FE, 3 => _MA, 4 => _AP, 5 => _MY, 6 => _JN, 7 => _JL, 8 => _AU, 9 => _SE, 10 => _OC, 11 => _NO, 12 => _DE); $tmpString = '<table width="100%" border="0" cellspacing="0" cellpadding="0">'; $iMonth = 1; for ($iRow = 0; $iRow < 3; $iRow++) { $tmpString .= '<tr>'; for ($iCol = 0; $iCol < 4; $iCol++) { $tmpString .= '<td><input type="button" id="isMonth" value="' . $miniMonth[$iMonth] . '" onclick="$(\'#jMonth\').val(' . $iMonth . ');$(\'#month_today\').monthSelect($(\'#jHour\').val(),$(\'#jMinute\').val(),$(\'#jDay\').val(), ' . $iMonth . ', $(\'#jYear\').val());" /></td>'; $iMonth++; } $tmpString .= '</tr>'; } $tmpString .= '</table>'; echo json_encode(array('list' => $tmpString, 'mName' => $nameMonth[$isToday['mon']] . ' ' . ($isToday['year'] + 543), 'date' => ThaiDate::Full(ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year'])), 'stamp' => ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year']), 'exdate' => ThaiDate::Full(ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year'] + 1)), 'exstamp' => ThaiDate::TimeStamp($_POST['cale_hour'], $_POST['cale_minute'], $_POST['cale_day'], $_POST['cale_month'], $_POST['cale_year'] + 1))); }
$idObject = '0' . $idObject; } $text .= '<br/><br/><span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT2 . $type['type_name'] . _CONTRACT_PRINT_IDOBJECT . $type['type_id'] . $idObject; $text .= _CONTRACT_PRINT_SIGNUP . ThaiDate::Mid($contract['signup_date']) . _CONTRACT_PRINT_TO . ThaiDate::Mid($contract['expire_date']) . _CONTRACT_PRINT_EXPIRE; $text .= _CONTRACT_PRINT_RENT . number_format($contract['cost'], 0) . _CONTRACT_PRINT_BAHT . _CONTRACT_PRINT_TEXT3; $text .= '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT4 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT5 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT6 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT7_1 . number_format($contract['deposite'], 0) . _CONTRACT_PRINT_TEXT7_2 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT8 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT9 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT10 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT11 . '</span><br/>'; $text .= '<span style="margin-left:35px;">' . _CONTRACT_PRINT_TEXT12 . '</span><br/>'; $data = array('id' => _CONTRACT_PASS . $contract['cus_id'] . $contract['object_id'] . $contract['emp_id'] . '-' . $contract['contract_id'], 'head' => _CONTRACT_PRINT_HEAD, 'singup' => _CONTRACT_TIME . ThaiDate::Full($contract['signup_date']), 'expire' => $expire, 'contract_type' => _CONTRACT_HEAD . $type['type_name'], 'text' => $text, 'personal' => _CONTRACT_PRINT_PERSONAL, 'own' => _CONTRACT_PRINT_OWN); $printButton = '<div style="position:fixed;top:10px;right:10px;"><input type="button" name="print" value="Print" onClick="javascript:window.print()"> <input type="button" name="close" value="Close" onClick="javascript:window.close()"></div>'; $content = site::Content('contract', $data); $targetDirectory = "document/"; $targetName = "contract"; $targetID = $contract['cus_id'] . $contract['object_id'] . $contract['emp_id'] . $contract['contract_id']; $targetExtension = ".html"; $fileName = $targetName . '_' . $targetID . $targetExtension; $isFile = fopen($targetDirectory . $fileName, 'w'); fputs($isFile, $printButton); fputs($isFile, $content); fclose($isFile); ?> <script> $(document).ready(function(){
</td> <td align="left" valign="top"> <table border="0" cellspacing="0" cellpadding="3"> <tr> <td colspan="2" align="left" valign="middle"><h4><?php echo _REGISTER_USER_PAYMENT; ?> </h4></td> </tr> <tr> <td align="right" valign="middle"><strong><?php echo _PAYMENT_LIST_TIME; ?> </strong></td> <td align="left"><div style="width:400px;word-wrap:break-word;"><?php echo ThaiDate::Full($payment['pay_date']); ?> </div></td> </tr> <tr> <td align="right" valign="middle"><strong><?php echo _PAYMENT_COST; ?> </strong></td> <td align="left"><div style="width:400px;word-wrap:break-word;"><?php echo number_format($payment['amount'], 2) . _CONTRACT_PRINT_BAHT; ?> </div></td> </tr> <tr> <td align="right" valign="top"><strong><?php
echo 'No. '; $idObject = $object['object_id']; while (strlen($idObject) < 3) { $idObject = '0' . $idObject; } echo '1' . $idObject; ?> </div> <div id="object-detail"> <?php echo '<div style="margin-bottom:6px;font-size:12px;text-decoration:underline;"><strong>' . $typeName['type_name'] . $object['detail'] . '</strong></div>'; if ($object['status_object'] == 1) { $contract = $database->Value('contract', array('object_id' => $object['object_id']), 0); $customer = $database->Value('customer', array('cus_id' => $contract['cus_id']), 0); echo '<div style="margin-bottom:3px;">' . _OBJECT_RENT_BY . ' <strong>' . $customer['fullname'] . '</strong></div>'; echo '<div style="margin-bottom:3px;">' . _OBJECT_RENT_DATE . ThaiDate::Full($contract['signup_date']) . '</div>'; } else { echo '<div>' . _OBJECT_RENT_BYNONE . '</div>'; echo '<span id="object-empty" class="select-' . $object['object_id'] . '">' . _OBJECT_RENT_BLANK . '</span>'; } ?> </div> </div></a> </td> <?php } ?> <?php if ($objectCount != 0) { while ($objectCount < 3) { echo '<td> </td>';
<td width="80" align="center">เวลาที่สอบ</td> </tr> <?php foreach ($database->Query("SELECT * FROM exam WHERE type='E' AND finish_date>={$isTime};") as $exam) { $isLesson = $database->Query("SELECT * FROM lesson_unit WHERE unit_id='{$exam['unit_id']}' LIMIT 1;"); ?> <tr height="28"> <td><strong><span style="margin-left:5px;"><a href="do_exam.php?opt=<?php echo $exam['exam_id']; ?> ">หน่วยการเรียนรู้ที่ <?php echo $exam['unit_id'] . ' ' . $isLesson['unit_name']; ?> </a></span></strong></td> <td><?php echo ThaiDate::Mid($exam['start_date']); ?> </td> <td align="center"> <?php $isStartTime = getdate($exam['start_date']); $isFinsihTime = getdate($exam['finish_date']); if (strlen($isStartTime['hours']) == 1) { echo '0'; } echo $isStartTime['hours'] . '.'; if (strlen($isStartTime['minutes']) == 1) { echo '0'; } echo $isStartTime['minutes'] . ' - '; if (strlen($isFinsihTime['hours']) == 1) {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <?php require "cgi-bin/SyncMySQL.php"; require "cgi-bin/ConfigSite.php"; ?> <body> <?php $database = new SyncDatabase(); foreach ($database->Query("SELECT * FROM ticket;") as $ticket) { echo 'User:'******'user_id']; echo '<br/>'; foreach ($database->Query("SELECT * FROM ticket_list WHERE ticket_id={$ticket['ticket_id']};") as $list) { $date = ThaiDate::Full($list['traveldate']); echo '-' . $date; echo '<br/>'; } } ?> </body> </html>
$tableConteact .= '<td style="border-top:#333 solid 2px;">' . number_format($totalMoney, 0) . _CONTRACT_PRINT_BAHT . '</td>'; $tableConteact .= '</tr>'; $UnitMoney = array('', _MONEY_1, _MONEY_2, _MONEY_3, _MONEY_4, _MONEY_5, _MONEY_6, '', _MONEY_7); $ThaiMoney = array(_MONEY_ONE, _MONEY_TWO, _MONEY_TREE, _MONEY_FOUR, _MONEY_FIVE, _MONEY_SIX, _MONEY_SEVEN, _MONEY_EIGHT, _MONEY_NINE); $lenMoney = strlen($totalMoney); $stringMoney = NULL; for ($iloop = 0; $iloop < $lenMoney; $iloop++) { $tmp = substr(strrev($totalMoney), $iloop, 1); if ($tmp != 0) { if ($iloop == 0) { $stringMoney = $ThaiMoney[$tmp - 1] . '' . $stringMoney; } elseif ($iloop == 1) { $stringMoney = $UnitMoney[8] . $UnitMoney[$iloop] . $stringMoney; } else { $stringMoney = $ThaiMoney[$tmp - 1] . $UnitMoney[$iloop] . $stringMoney; } } } $tableConteact .= '<tr><td align="right" colspan="2">' . $stringMoney . _CONTRACT_PRINT_BAHT . '</td>'; $tableConteact .= '</tr>'; $tableConteact .= '</table>'; $data = array('head' => _CONTRACT_PRINT_HEAD, 'date' => _REPORT4_DATE . ThaiDate::Full(time()), 'report_type' => _REPORT3_HEAD1 . $type['type_name'] . _REPORT3_HEAD2 . $date, 'text' => $tableConteact, 'personal' => _REPORT_SIGN); $content = site::Content('report1', $data); $targetDirectory = "document/"; $fileName = 'report4_' . $type['type_id'] . '-' . $key . '.html'; $isFile = fopen($targetDirectory . $fileName, 'w'); fputs($isFile, $printButton); fputs($isFile, $content); fclose($isFile); } }
$beginPath = $database->Query("SELECT * FROM place WHERE place_id={$path['begin_id']} LIMIT 1"); $endPath = $database->Query("SELECT * FROM place WHERE place_id={$path['finish_id']} LIMIT 1"); ?> <table width="550" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="20" align="right"> </td> <td width="250"><?php echo $beginPath['place'] . '-' . $endPath['place']; ?> </td> <td width="80" align="center">ที่นั่ง <?php echo $list['seat']; ?> </td> <td width="200"><?php echo ThaiDate::Mid($list['traveldate']); ?> </td> </tr> </table><?php $travel = $database->Query("SELECT * FROM travel WHERE travel_id={$list['travel_id']} LIMIT 1;"); $price += $travel['fare']; } ?> <hr width="550" align="left" /> <table width="550" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="400" align="right"><strong>ราคารวม : </strong></td> <td width="50" align="right"><?php echo number_format($price, 2); ?>
<?php $database = new SyncDatabase(); foreach ($database->Query("SELECT * FROM old_list WHERE user_id={$_COOKIE['USER']} AND view=1;") as $list) { ?> <table align="center" width="550" border="0" cellspacing="0" cellpadding="2"> <tr> <td align="left" width="300"><a style="color:#900;" onclick="delOldList(<?php echo $list['old_id']; ?> )"><strong>x</strong></a> <?php echo ThaiDate::Mid($list['time']); ?> </td> <td align="center" width="170"><?php $path = $database->Query("SELECT * FROM path WHERE path_id=(SELECT path_id FROM travel WHERE travel_id={$list['travel_id']}) LIMIT 1"); $beginPath = $database->Query("SELECT * FROM place WHERE place_id={$path['begin_id']} LIMIT 1"); $endPath = $database->Query("SELECT * FROM place WHERE place_id={$path['finish_id']} LIMIT 1"); $car = $database->Query("SELECT * FROM car WHERE car_id=(SELECT car_id FROM travel WHERE travel_id={$list['travel_id']}) LIMIT 1"); echo $beginPath['place'] . '-' . $endPath['place']; ?> </td> <td align="center" width="80"><?php echo $car['regis']; ?> </td> </tr> </table><?php } ?> <table width="100%" align="center" border="0" cellspacing="0" cellpadding="10" style="border-top:#E6E6E6 solid 1px;">
} if ($colorRow % 2 == 0) { $style = 'style="background-color:#F7F7F7;"'; } else { $style = ''; } echo '<a href="?contract=edit&id=' . $contract['contract_id'] . '">'; echo '<table align="right" width="100%" border="0" cellspacing="0" cellpadding="3" id="list-user" ' . $style . '>'; echo '<tr style="height:30px" class="list-select">'; echo '<td align="right"><div style="width:100px;"><strong>' . $idContract . '</strong></div></td>'; echo '<td align="center"><div style="width:140px;">' . $customer['fullname'] . '</div></td>'; echo '<td align="center"><div style="width:50px;">' . $objectType['type_name'] . '</div></td>'; echo '<td align="right"><div style="width:80px;">' . number_format($contract['cost'], 2) . '</div></td>'; echo '<td align="right"><div style="width:80px;">' . number_format($costCharge, 2) . '</div></td>'; echo '<td align="right"><div style="width:120px;">' . ThaiDate::Mid($contract['signup_date']) . '</div></td>'; echo '<td align="right"><div style="width:120px;">' . ThaiDate::Mid($contract['expire_date']) . '</div></td>'; echo '<td align="center"><div style="width:20px;"><a href="?object=view&id=' . $contract['object_id'] . '">'; if ($contract['canceled'] != 1) { echo '<img src="images/thumbnail_large.gif" width="14" height="14" border="0" align="absmiddle" />'; } echo '</a></div></td></tr></table></a>'; $colorRow++; } if ($database->Count('contract', 0, 0) == 0) { echo '<table align="right" width="100%" border="0" cellspacing="0" cellpadding="3" id="list-user"><tr style="height:30px"><td align="center" align="center" colspan="8">'; echo '<strong>' . _REGISTER_NONE . '</strong>'; echo '</td></tr></table>'; } ?> </td> </tr>
} $paymentInsert = array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost'], 'pay_date' => ThaiDate::TimeStamp(7, $isPaydate['mon'], $isPaydate['year'])); $database->Insert('payment', $paymentInsert); } } // Payment Charge Now foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost'], 'paid' => 0), 0) as $payment) { $isPaydate = getdate($payment['pay_date']); if ($isPaydate['mon'] < $isToday['mon'] || $isPaydate['year'] < $isToday['year']) { $isNextMonth = $isPaydate['mon'] + 1; $isNextYear = $isPaydate['year']; if ($isNextMonth > 12) { $isNextMonth = 1; $isNextYear += 1; } $chargeMoney = (ThaiDate::TimeStamp(7, $isNextMonth, $isNextYear) - $payment['pay_date']) / 86400 * $isCharge; $database->Update('payment', array('charge' => $chargeMoney), array('pay_id' => $payment['pay_id'])); } elseif ($isPaydate['mon'] == $isToday['mon'] && $isPaydate['year'] == $isToday['year']) { $chargeMoney = (int) floor((time() - $payment['pay_date']) / 86400) * $isCharge; $database->Update('payment', array('charge' => $chargeMoney), array('pay_id' => $payment['pay_id'])); } } } //endif } //endif } //endforeach foreach ($database->Select('contract', array('canceled' => 1), 0) as $contract) { // Payment Delete foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost'], 'paid' => 0), 0) as $payment) {
foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'paid' => 0), 0) as $payment) { $listMoney .= '<tr><td align="left" valign="middle"><span style="margin-left:40px;">'; if ($payment['amount'] == 1000 || $payment['amount'] == 2000) { $listMoney .= _PAYMENT_PAYRENT; } else { $listMoney .= _PAYMENT_DEPOSITE; } $listMoney .= '</span></td>'; $listMoney .= '<td align="right" valign="middle"><span style="margin-left:40px;">' . number_format($payment['amount'] + $payment['charge'], 2) . '</span></td></tr>'; if ($payment['pay_date'] > $dueDate) { $dueDate = $payment['pay_date']; } $moneyTotal += $payment['amount'] + $payment['charge']; } $listMoney .= '</table>'; $data = array('head' => _CONTRACT_PRINT_HEAD, 'today' => _INVOICE_DAY . ThaiDate::Full(time()), 'invoice' => _INVOICE_HEAD, 'contract_id' => '<strong>' . _INVOICE_CONTRACT_NUMBER . '</strong> ' . $contract['cus_id'] . $contract['object_id'] . $contract['emp_id'] . '-' . $contract['contract_id'], 'object_id' => '<strong>' . _CONTRACT_PRINT_OBJECT . $type['type_name'] . '</strong> ' . $type['type_id'] . $idObject, 'name' => '<strong>' . _REGISTER_FULLNAME . '</strong> ' . $customer['fullname'], 'address' => '<strong>' . _REGISTER_ADDRESS . '</strong> ' . $customer['address'], 'due_date' => '<strong>' . _INVOICE_PAY_DUE . '</strong> ' . ThaiDate::Full($dueDate), 'pay_head' => '<strong>' . _INVOICE_PAY_HEADTOTAL . '</strong>', 'list' => $listMoney, 'pay_total' => '<strong>' . _INVOICE_PAY_TOTAL . '</strong>', 'pay_money_total' => '<strong>' . number_format($moneyTotal, 2) . '</strong>', 'personal' => _INVOICE_PAY_MONEY); $printButton = '<div style="position:fixed;top:10px;right:10px;"><input type="button" name="print" value="Print" onClick="javascript:window.print()"> <input type="button" name="close" value="Close" onClick="javascript:window.close()"></div>'; $content = site::Content('invoice', $data); $targetDirectory = "document/"; $targetName = "invoice"; $targetID = $contract['cus_id'] . $contract['object_id'] . $contract['emp_id'] . $contract['contract_id']; $targetExtension = ".html"; $fileName = $targetName . '_' . $targetID . $targetExtension; $isFile = fopen($targetDirectory . $fileName, 'w'); fputs($isFile, $printButton); fputs($isFile, $content); fclose($isFile); ?> <script> $(document).ready(function(){