$database = new SyncDatabase(); $colorRow = 1; foreach ($database->Select('customer', 0, 0) as $customer) { $listCustomer[$customer['cus_id']] = array(); $listCustomer[$customer['cus_id']]['pay'] = 0; $listCustomer[$customer['cus_id']]['charge'] = 0; $listCustomer[$customer['cus_id']]['total'] = 0; $listCustomer[$customer['cus_id']]['list'] = 0; foreach ($database->Select('contract', array('cus_id' => $customer['cus_id']), 0) as $contract) { $listCustomer[$customer['cus_id']]['object'] = $database->Value('object_rental', array('object_id' => $contract['object_id']), 0); $listCustomer[$customer['cus_id']]['type'] = $database->Value('object_type', array('type_id' => $listCustomer[$customer['cus_id']]['object']['type_id']), 0); $listCustomer[$customer['cus_id']]['payment'] = $database->Value('payment', array('contract_id' => $contract['contract_id'], 'paid' => 0), 0); $listCustomer[$customer['cus_id']]['object'] = $listCustomer[$customer['cus_id']]['object']['detail']; $listCustomer[$customer['cus_id']]['type'] = $listCustomer[$customer['cus_id']]['type']['type_name']; $listCustomer[$customer['cus_id']]['payment'] = $listCustomer[$customer['cus_id']]['payment']['pay_date']; $listCustomer[$customer['cus_id']]['paid'] = $database->Count('payment', array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost'], 'paid' => 0), 0); foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'paid' => 0), 0) as $payment) { $listCustomer[$customer['cus_id']]['list']++; $listCustomer[$customer['cus_id']]['pay'] += $payment['amount']; $listCustomer[$customer['cus_id']]['charge'] += $payment['charge']; $listCustomer[$customer['cus_id']]['total'] += $payment['amount'] + $payment['charge']; } } if ($listCustomer[$customer['cus_id']]['total'] != 0) { if ($listCustomer[$customer['cus_id']]['paid'] > 2) { $style = 'style="background-color:#f6aaaa;"'; } else { if ($listCustomer[$customer['cus_id']]['paid'] > 1) { $style = 'style="background-color:#f6f3aa;"'; } else { $style = 'style="background-color:#ccffcc;"';
} if ($listCustomer[$contract['cus_id']]['total'] != 0) { echo '<a href="?invoice=print&id=' . $contract['contract_id'] . '">'; } echo '<table align="left" width="100%" border="0" cellspacing="0" cellpadding="3" class="list-space" id="user_' . $customer['cus_id'] . '" ' . $style . '>'; echo '<tr style="height:30px"'; if ($listCustomer[$contract['cus_id']]['total'] != 0) { echo ' class="list-select"'; } echo '><td align="center"><div style="width:35px;" id="img_' . $customer['cus_id'] . '">' . $colorRow . '</div></td>'; echo '<td align="center"><div style="width:5px;" id="id' . $customer['cus_id'] . '"></div></td>'; echo '<td align="left"><div style="width:200px;word-wrap:break-word;"><strong>' . $customer['fullname'] . '</strong></div></td>'; echo '<td align="left"><div style="width:140px;word-wrap:break-word;"><strong>' . $objectType['type_name'] . $object['detail'] . '</strong></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>'; if ($listCustomer[$contract['cus_id']]['total'] != 0) { echo '</a>'; } $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>'; } ?> </td> </tr> </table>
echo '<table align="left" width="100%" border="0" cellspacing="0" cellpadding="3" id="user_' . $user['emp_id'] . '" ' . $style . '>'; echo '<tr style="height:30px" class="list-select">'; echo '<td align="center"><div style="width:35px;" id="img_' . $user['emp_id'] . '">' . $colorRow . '</div></td>'; echo '<td align="center"><div style="width:5px;" id="id' . $user['emp_id'] . '"></div></td>'; echo '<td align="left"><div style="width:90px;">' . $user['username'] . '</div></td>'; echo '<td align="left"><div style="width:120px;"><strong>' . $user['emp_name'] . '</strong></div></td>'; echo '<td align="left"><div style="width:350px;word-wrap:break-word;">' . $user['address'] . '</div></td>'; echo '<td align="left"><div style="width:85px;">' . $user['telephone'] . '</div></td>'; echo '<td align="center"><div style="width:20px;">'; if ($user['picture'] != 'user_none.jpg') { echo '<img src="images/thumbnail_large.gif" width="14" height="14" border="0" align="absmiddle" />'; } echo '</div></td></tr></table></a>'; $colorRow++; } if ($database->Count('employee', 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> </table> <script> $(document).ready(function(){ $('#event_main').show(0); $('#action_add').click(function(){ $(this).href('employee=add'); }); var emp_id = [<?php
?> " disabled="disabled" /> <input type="button" id="action_back" class="button" value=" " title="<?php echo _IMAGE_TAG_BACK; ?> " /> </div> <br /><div align="left"><h1><?php echo _HEAD_LIST_OBJECT; ?> </h1></div> <table align="left" width="100%" border="0" cellspacing="0" cellpadding="0" style="border-top:#999 dashed 1px;"> <tr> <td valign="top" width="230" style="border-right:#666 solid 2px;"> <?php $objectCount = $database->Count('object_rental', array('type_id' => 2), 0); $objectRow = floor($objectCount / 3) + 1; $objectName = $database->Select('object_type', array('type_id' => 2), 0); $objectName = $objectName[0]['type_name']; ?> <table width="235" border="0" cellspacing="1" cellpadding="3"> <?php foreach ($database->Select('object_rental', array('type_id' => 2), 0) as $object) { ?> <tr> <td> <a href="?object=edit&id=<?php echo $object['object_id']; ?> "> <div <?php
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> </table> <script> $(document).ready(function(){ $('#event_main').show(0); $('#action_regis').click(function(){ $(this).href('contract=register'); }); var cus_id = [<?php
$control->setCookie('USER_RENTAL', $_POST['username'], $GLOBALS['TIME_COOKIE']); } if ($control->Value('USER_RENTAL')) { $control->setCookie('USER_RENTAL', $control->Value('USER_RENTAL'), $GLOBALS['TIME_COOKIE']); $control->setSession('LOGIN_VAILD', $_SERVER['REQUEST_URI']); foreach ($database->Select('contract', array('canceled' => 0), 0) as $contract) { $isToday = getdate(time()); $isCharge = 50; $isChargeMonth = 3; // Canceled Contract Expire if ($contract['cancel_date'] != 0 && $contract['cancel_date'] < time() || $contract['expire_date'] < time()) { $database->Update('contract', array('canceled' => 1), array('contract_id' => $contract['contract_id'])); $database->Update('object_rental', array('status_object' => 0), array('object_id' => $contract['object_id'])); } else { // Canceled Contract Over 3 Month if ($database->Count('payment', array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost'], 'paid' => 0), 0) > $isChargeMonth) { $database->Update('contract', array('cancel_date' => time(), 'canceled' => 1), array('contract_id' => $contract['contract_id'])); $database->Update('object_rental', array('status_object' => 0), array('object_id' => $contract['object_id'])); } else { // Payment Month Insert if ($database->Count('payment', array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost']), 0) == 0) { $isSignup = getdate($contract['signup_date']); $isSignup['mon'] += 1; if ($isSignup['mon'] > 12) { $isSignup['mon'] = 1; $isSignup['year'] += 1; } $paymentInsert = array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost'], 'pay_date' => ThaiDate::TimeStamp(7, $isSignup['mon'], $isSignup['year'])); $database->Insert('payment', $paymentInsert); } foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'amount' => $contract['cost']), array(0, 0, 'ORDER BY pay_date DESC LIMIT 0,1')) as $payment) {
</div> --> </td> </tr> </table> </td> <td width="220" style="border-left:#CCC dashed 1px;" valign="top"> <h4><?php echo _STATUS_SAMMARY; ?> </h4> <div style="padding:0 0 5px 15px; background-color:#F99"> <?php foreach ($database->Select('object_type', 0, 0) as $rental) { echo '<strong>' . $rental['type_name'] . '</strong> '; echo $database->Count('object_rental', array('type_id' => $rental['type_id'], 'status_object' => '0'), 0); echo '(' . $database->Count('object_rental', array('type_id' => $rental['type_id']), 0) . ')'; echo '<br />'; } echo '<strong>' . _STATUS_CUSTOMER_TOTAL . '</strong> '; echo $database->Count('customer', 0, 0) . _STATUS_UNIT; echo '<br />'; echo '<strong>' . _STATUS_CUSTOMER_PAY . '</strong> '; $paidCount = 0; foreach ($database->Select('customer', 0, 0) as $customer) { foreach ($database->Select('contract', array('cus_id' => $customer['cus_id']), 0) as $contract) { if ($database->Count('payment', array('contract_id' => $contract['contract_id'], 'paid' => 0), 0) != 0) { $paidCount++; } } }