<?php if (isset($_GET['action']) && isset($_POST['register_apply'])) { $database = new SyncDatabase(); if (!$database->Select('customer', array('idcard' => $_REQUEST['regis_idcard']), 0)) { $newCustomer = array('regis_date' => $_SERVER['REQUEST_TIME'], 'fullname' => $_REQUEST['regis_fullname'], 'address' => $_REQUEST['regis_address'], 'idcard' => $_REQUEST['regis_idcard'], 'telephone' => $_REQUEST['regis_telephone'], 'job' => $_REQUEST['regis_job']); $database->Insert('customer', $newCustomer); } ?> <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_edit" id="register_edit" value=" " title="<?php echo _IMAGE_TAG_EDIT; ?> " /> <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_ADD; ?> </h4> <table border="0" cellspacing="0" cellpadding="3"> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"> </td> </tr>
<?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;
} 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) { $isPaydate = getdate($payment['pay_date']); while ($isPaydate['mon'] <= $isToday['mon'] || $isPaydate['year'] < $isToday['year']) { $isPaydate['mon'] += 1; if ($isPaydate['mon'] > 12) { $isPaydate['mon'] = 1; $isPaydate['year'] += 1; } $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) {
unlink($filename); } $imageVailds = true; } else { $imageVailds = false; $isFile['basename'] = 'user_none.jpg'; $isAttrImage = 'width="110" height="128"'; } } else { $imageVailds = false; $isFile['basename'] = 'user_none.jpg'; $isAttrImage = 'width="110" height="128"'; } if (!$database->Select('employee', array('username' => $_REQUEST['regis_username']), 0)) { $newUser = array('emp_name' => $_REQUEST['regis_fullname'], 'address' => $_REQUEST['regis_address'], 'telephone' => $_REQUEST['regis_telephone'], 'picture' => $isFile['basename'], 'username' => $_REQUEST['regis_username'], 'password' => $_REQUEST['regis_password']); $database->Insert('employee', $newUser); } ?> <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_edit" id="register_edit" value=" " title="<?php echo _IMAGE_TAG_EDIT; ?> " /> <input type="button" name="register_success" id="register_success" value=" " title="<?php echo _IMAGE_TAG_SUBMIT; ?> " /> </td> <td align="left" valign="top">
<?php $database = new SyncDatabase(); if (isset($_GET['action']) && isset($_POST['register_apply'])) { $newObject = array('detail' => $_REQUEST['regis_detail'], 'type_id' => $_REQUEST['regis_type']); $database->Insert('object_rental', $newObject); ?> <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_OBJECT_ADD; ?> </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_TYPE; ?> :</strong></td> <td align="left" valign="top"><?php