<?php $database = new SyncDatabase(); if (!isset($_GET['action'])) { $_GET['action'] = ''; } if ($_GET['action'] == 'pay') { if (isset($_GET['id'])) { $database->Update('payment', array('paid' => 1), array('pay_id' => $_GET['id'])); header("Location:?pay=ment"); exit; } elseif (isset($_GET['customer'])) { foreach ($database->Select('contract', array('cus_id' => $_GET['customer']), 0) as $contract) { $database->Update('payment', array('paid' => 1), array('contract_id' => $contract['contract_id'])); } header("Location:?pay=ment"); exit; } } else { if (isset($_GET['customer'])) { $customer = $database->Value('customer', array('cus_id' => $_GET['customer']), 0); $listCustomer['pay'] = 0; $listCustomer['charge'] = 0; $listCustomer['total'] = 0; foreach ($database->Select('contract', array('cus_id' => $customer['cus_id']), 0) as $contract) { foreach ($database->Select('payment', array('contract_id' => $contract['contract_id'], 'paid' => 0), 0) as $payment) { $listCustomer['pay'] += $payment['amount']; $listCustomer['charge'] += $payment['charge']; $listCustomer['total'] += $payment['amount'] + $payment['charge']; } }
<?php $database = new SyncDatabase(); $contract = $database->Value('contract', array('contract_id' => $_GET['id']), 0); if (!isset($_GET['action'])) { $_GET['action'] = ''; } if ($_GET['action'] == 'confirm') { $editContract = array('cancel_date' => $_REQUEST['timestamp']); $database->Update('contract', $editContract, array('contract_id' => $_GET['id'])); ?> <script> $(document).ready(function() { $(this).href('contract=edit&id=<?php echo $_GET['id']; ?> '); }); </script><?php } elseif ($_GET['action'] == 'canceled') { $isToday = getdate(time()); ?> <form name="canceled" method="post" action="?contract=edit&id=<?php echo $_GET['id']; ?> &action=confirm"> <table width="100%" cellpadding="5" cellspacing="0" border="0"> <tr> <td width="180" align="center" valign="top" style="border-right:#CCC dashed 1px;"> <input type="submit" name="register_save" id="register_save" value=" " title="<?php echo _IMAGE_TAG_SAVE;
$folder_taget = 'images/employee/' . $isFile['basename']; copy($_REQUEST['regis_picture'], $folder_taget); foreach (glob("images/tmpuser/*.*") as $filename) { unlink($filename); } $imageVailds = true; } } $editUser = array('emp_name' => $_REQUEST['regis_fullname'], 'address' => $_REQUEST['regis_address'], 'telephone' => $_REQUEST['regis_telephone']); if ($isFile['basename'] !== $employee['picture']) { $editUser['picture'] = $isFile['basename']; } if ($_REQUEST['regis_password'] !== $employee['password'] && $_REQUEST['regis_password'] !== '') { $editUser['password'] = $_REQUEST['regis_password']; } $database->Update('employee', $editUser, array('username' => $_GET['username'])); ?> <table width="100%" cellpadding="5" cellspacing="0" border="0"> <tr> <td width="180" align="center" valign="top" style="border-right:#CCC dashed 1px;"> <input type="button" name="register_success" id="register_success" value=" " title="<?php echo _IMAGE_TAG_SUBMIT; ?> " /> </td> <td align="left" valign="top"> <h4><?php echo _REGISTER_USER_EDIT; ?> </h4> <table border="0" cellspacing="0" cellpadding="3">
<?php $control = new Session(); $database = new SyncDatabase(); if (isset($_GET['action']) && isset($_POST['register_apply'])) { $customer = $database->Value('customer', array('cus_id' => $_REQUEST['regis_customer']), 0); $object = $database->Value('object_rental', array('object_id' => $_REQUEST['regis_object']), 0); $type = $database->Value('object_type', array('type_id' => $object['type_id']), 0); $user = $database->Value('employee', array('username' => $control->Value('USER_RENTAL')), 0); $newContract = array('cus_id' => $_REQUEST['regis_customer'], 'emp_id' => $user['emp_id'], 'object_id' => $_REQUEST['regis_object'], 'cost' => $type['rentalcost'], 'deposite' => $type['rentalcost'] * 3, 'signup_date' => $_REQUEST['timestamp_signup'], 'expire_date' => $_REQUEST['timestamp_expire']); $database->Insert('contract', $newContract); $idContract = $database->Value('contract', array('signup_date' => $_REQUEST['timestamp_signup']), 0); $newPayment = array('contract_id' => $idContract['contract_id'], 'amount' => $type['rentalcost'] * 3, 'pay_date' => $_REQUEST['timestamp_signup']); $database->Insert('payment', $newPayment); $database->Update('object_rental', array('status_object' => 1), array('object_id' => $object['object_id'])); ?> <table width="100%" cellpadding="5" cellspacing="0" border="0"> <tr> <td width="180" align="center" valign="top" style="border-right:#CCC dashed 1px;"> <input type="button" name="register_pay" id="register_pay" value=" " title="<?php echo _IMAGE_TAG_PAY; ?> " /> <input type="button" name="register_success" id="register_success" value=" " title="<?php echo _IMAGE_TAG_BACK; ?> " /> </td> <td align="left" valign="top"> <h4><?php echo _REGISTER_CUSTOMER_ADD;
<?php } else { if (isset($_POST['login_submit'])) { $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; }
<?php $database = new SyncDatabase(); $customer = $database->Value('customer', array('cus_id' => $_GET['id']), 0); if (isset($_GET['action']) && isset($_POST['register_edit'])) { $editCustomer = array('fullname' => $_REQUEST['regis_fullname'], 'address' => $_REQUEST['regis_address'], 'idcard' => $_REQUEST['regis_idcard'], 'telephone' => $_REQUEST['regis_telephone'], 'job' => $_REQUEST['regis_job']); $database->Update('customer', $editCustomer, array('cus_id' => $_GET['id'])); ?> <table width="100%" cellpadding="5" cellspacing="0" border="0"> <tr> <td width="180" align="center" valign="top" style="border-right:#CCC dashed 1px;"> <input type="button" name="register_success" id="register_success" value=" " title="<?php echo _IMAGE_TAG_SUBMIT; ?> " /> </td> <td align="left" valign="top"> <h4><?php echo _REGISTER_CUSTOMER_EDIT; ?> </h4> <table border="0" cellspacing="0" cellpadding="3"> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td align="right" valign="top"><strong><?php echo _REGISTER_FULLNAME; ?> :</strong></td>