public function extend() { $query = "INSERT INTO job_extensions \n SELECT 0, id, created_on, expire_on, for_replacement, invoiced \n FROM jobs \n WHERE id = " . $this->id; if ($this->mysqli->execute($query) === false) { return false; } $query = "SELECT expire_on FROM jobs \n WHERE id = " . $this->id . " LIMIT 1"; $result = $this->mysqli->query($query); $is_expired = sql_date_diff($result[0]['expire_on'], now()) <= 0 ? true : false; $expire_on = $result[0]['expire_on']; if ($is_expired) { $expire_on = now(); } $data = array(); $data['created_on'] = $expire_on; $data['expire_on'] = sql_date_add($data['created_on'], 30, 'day'); $data['closed'] = 'N'; if ($this->update($data) == false) { return false; } return true; }
if ($_POST['action'] == 'get_invoices') { $result = get_payments(true, $_POST['order_by'], $_POST['filter']); if (count($result) <= 0 || is_null($result)) { echo '0'; exit; } if (!$result) { echo 'ko'; exit; } $today = today(); foreach ($result as $i => $row) { $result[$i]['employer'] = htmlspecialchars_decode(stripslashes($row['employer'])); $result[$i]['padded_id'] = pad($row['id'], 11, '0'); $result[$i]['amount_payable'] = number_format($row['amount_payable'], 2, '.', ', '); $delta = sql_date_diff($today, $row['payable_by']); if ($delta > 0) { $result[$i]['expired'] = 'expired'; } else { if ($delta == 0) { $result[$i]['expired'] = 'nearly'; } else { $result[$i]['expired'] = 'no'; } } } $response = array('invoices' => array('invoice' => $result)); header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array($response); exit; }
exit; } } else { $employer->used_paid_job_posting(); } } else { $employer->used_free_job_posting(); } $query = "INSERT INTO job_extensions \n SELECT 0, id, created_on, expire_on, for_replacement, invoiced FROM jobs WHERE id = " . $_POST['job']; if (!$mysqli->execute($query)) { echo "ko"; exit; } $query = "SELECT expire_on \n FROM jobs \n WHERE id = " . $_POST['job'] . " LIMIT 1"; $result = $mysqli->query($query); $is_expired = sql_date_diff($result[0]['expire_on'], now()) <= 0 ? true : false; $expire_on = $result[0]['expire_on']; if ($is_expired) { $expire_on = now(); } $data = array(); $data['created_on'] = $expire_on; $data['expire_on'] = sql_date_add($data['created_on'], 30, 'day'); $data['closed'] = 'N'; $job = new Job($_POST['job']); if ($job->update($data) == false) { echo "ko"; exit; } echo "ok"; exit;
public function show() { $this->begin(); $branch = $this->employee->getBranch(); $this->top('Payments - ' . $branch[0]['country']); $this->menu_employee('payments'); $employers = $this->get_employers(); $receipt_employers = $this->get_employers(false); $today = now(); $invoices = $this->get_payments(); foreach ($invoices as $i => $row) { $invoices[$i]['padded_id'] = pad($row['id'], 11, '0'); $invoices[$i]['amount_payable'] = number_format($row['amount_payable'], 2, '.', ', '); $delta = sql_date_diff($today, $row['payable_by']); if ($delta > 0) { $invoices[$i]['expired'] = 'expired'; } else { if ($delta == 0) { $invoices[$i]['expired'] = 'nearly'; } else { $invoices[$i]['expired'] = 'no'; } } } $receipts = $this->get_payments(false); foreach ($receipts as $i => $row) { $receipts[$i]['padded_id'] = pad($row['id'], 11, '0'); $receipts[$i]['amount_payable'] = number_format($row['amount_payable'], 2, '.', ', '); } ?> <!-- submenu --> <div class="menu"> <ul class="menu"> <li id="item_invoices" style="background-color: #CCCCCC;"><a class="menu" onClick="show_invoices();">Invoices</a></li> <li id="item_receipts"><a class="menu" onClick="show_receipts();">Receipts</a></li> </ul> </div> <!-- end submenu --> <div id="div_status" class="status"> <span id="span_status" class="status"></span> </div> <div id="invoices"> <?php if (is_null($invoices) || count($invoices) <= 0 || $invoices === false) { ?> <div class="empty_results">No invoices issued at this moment.</div> <?php } else { ?> <div class="buttons_bar"> Employer Filter: <select id="invoices_filter" onChange="filter_invoices();"> <option value="" selected>All</option> <option value="" disabled> </option> <?php foreach ($employers as $employer) { ?> <option value="<?php echo $employer['id']; ?> "><?php echo htmlspecialchars_decode(stripslashes($employer['employer'])); ?> </option> <?php } ?> </select> </div> <div id="div_invoices"> <?php $invoices_table = new HTMLTable('invoices_table', 'invoices'); $invoices_table->set(0, 0, ' ', '', 'header expiry_status'); $invoices_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'invoices.issued_on');\">Issued On</a>", '', 'header'); $invoices_table->set(0, 2, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'employers.name');\">Employer</a>", '', 'header'); $invoices_table->set(0, 3, "Placement", '', 'header'); $invoices_table->set(0, 4, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'invoices.id');\">Invoice</a>", '', 'header'); $invoices_table->set(0, 5, 'Payable By', '', 'header'); $invoices_table->set(0, 6, 'Amount Payable', '', 'header'); $invoices_table->set(0, 7, 'Actions', '', 'header action'); foreach ($invoices as $i => $invoice) { $status = ''; if ($invoice['expired'] == 'expired') { $status = '<img class="warning" src="../common/images/icons/expired.png" />'; } elseif ($invoice['expired'] == 'nearly') { $status = '<img class="warning" src="../common/images/icons/just_expired.png" />'; } $invoices_table->set($i + 1, 0, $status, '', 'cell expiry_status'); $invoices_table->set($i + 1, 1, $invoice['formatted_issued_on'], '', 'cell'); $employer_contacts = htmlspecialchars_decode(stripslashes($invoice['employer'])); $employer_contacts .= '<div class="contacts">'; $employer_contacts .= '<span class="contact_label">Tel.:</span> ' . $invoice['phone_num'] . '<br/>'; $employer_contacts .= '<span class="contact_label">Fax.:</span> ' . $invoice['fax_num'] . '<br/>'; $employer_contacts .= '<span class="contact_label">E-mail:</span> <a href="mailto:' . $invoice['email_addr'] . '">' . $invoice['email_addr'] . '</a><br/>'; $employer_contacts .= '<span class="contact_label">Contact:</span> ' . $invoice['contact_person'] . '<br/></div>'; $invoices_table->set($i + 1, 2, $employer_contacts, '', 'cell'); $invoices_table->set($i + 1, 3, $invoice['placement'], '', 'cell'); $invoices_table->set($i + 1, 4, '<a class="no_link" onClick="show_invoice_page(' . $invoice['id'] . ');">' . $invoice['padded_id'] . '</a> <a href="invoice_pdf.php?id=' . $invoice['id'] . '"><img src="../common/images/icons/pdf.gif" /></a>', '', 'cell'); $invoices_table->set($i + 1, 5, $invoice['formatted_payable_by'], '', 'cell'); $amount = $invoice['currency'] . '$ ' . $invoice['amount_payable']; $invoices_table->set($i + 1, 6, $amount, '', 'cell'); $actions = '<input type="button" value="Paid" onClick="show_payment_popup(' . $invoice['id'] . ', \'' . $invoice['padded_id'] . '\');" /><input type="button" value="Resend" onClick="show_resend_popup(' . $invoice['id'] . ', \'' . $invoice['padded_id'] . '\');" />'; $invoices_table->set($i + 1, 7, $actions, '', 'cell action'); } echo $invoices_table->get_html(); ?> </div> <?php } ?> </div> <div id="receipts"> <?php if (is_null($receipts) || count($receipts) <= 0 || $receipts === false) { ?> <div class="empty_results">No receipts issued at this moment.</div> <?php } else { ?> <div class="buttons_bar"> Employer Filter: <select id="receipts_filter" onChange="filter_receipts();"> <option value="" selected>All</option> <option value="" disabled> </option> <?php foreach ($receipt_employers as $employer) { ?> <option value="<?php echo $employer['id']; ?> "><?php echo htmlspecialchars_decode(stripslashes($employer['employer'])); ?> </option> <?php } ?> </select> </div> <div id="div_receipts"> <?php $receipts_table = new HTMLTable('receipts_table', 'receipts'); $receipts_table->set(0, 0, "<a class=\"sortable\" onClick=\"sort_by('receipts', 'receipts.issued_on');\">Issued On</a>", '', 'header'); $receipts_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('receipts', 'employers.name');\">Employer</a>", '', 'header'); $receipts_table->set(0, 2, 'Placement', '', 'header'); $receipts_table->set(0, 3, "<a class=\"sortable\" onClick=\"sort_by('receipts', 'invoices.id');\">Receipt</a>", '', 'header'); $receipts_table->set(0, 4, 'Paid On', '', 'header'); $receipts_table->set(0, 5, 'Amount Paid', '', 'header'); $receipts_table->set(0, 6, 'Payment', '', 'header payment'); foreach ($receipts as $i => $receipt) { $receipts_table->set($i + 1, 0, $receipt['formatted_issued_on'], '', 'cell'); $receipts_table->set($i + 1, 1, htmlspecialchars_decode(stripslashes($receipt['employer'])), '', 'cell'); $receipts_table->set($i + 1, 2, $receipt['placement'], '', 'cell'); $receipts_table->set($i + 1, 3, '<a class="no_link" onClick="show_receipt_page(' . $receipt['id'] . ');">' . $receipt['padded_id'] . '</a> <a href="invoice_pdf.php?id=' . $receipt['id'] . '"><img src="../common/images/icons/pdf.gif" /></a>', '', 'cell'); $receipts_table->set($i + 1, 4, $receipt['formatted_paid_on'], '', 'cell'); $amount = $receipt['currency'] . '$ ' . $receipt['amount_payable']; $receipts_table->set($i + 1, 5, $amount, '', 'cell'); $payment = 'By Cash'; if ($receipt['paid_through'] != 'CSH') { $payment = 'Bank Receipt #:<br/>' . $receipt['paid_id']; } $receipts_table->set($i + 1, 6, $payment, '', 'cell payment'); } echo $receipts_table->get_html(); ?> </div> <?php } ?> </div> <!-- popup windows goes here --> <div id="paid_window" class="popup_window"> <div class="popup_window_title">Confirm Payment</div> <form onSubmit="return false;"> <input type="hidden" id="invoice_id" value="" /> <div class="paid_form"> <table class="paid_form"> <tr> <td class="label">Invoice:</td> <td class="field"><span id="lbl_invoice"></span></td> </tr> <tr> <td class="label">Paid On:</td> <td class="field"> <?php echo generate_dropdown('day', 'day', 1, 31, '', 2, 'Day'); echo generate_month_dropdown('month', 'month', 'Month'); $today = explode('-', today()); $year = $today[0]; echo generate_dropdown('year', 'year', $year - 1, $year, '', 4, 'Year'); ?> </td> </tr> <tr> <td class="label">Payment Mode:</td> <td class="field"> <select class="field" id="payment_mode" name="payment_mode"> <option value="CSH">Cash</option> <option value="IBT">Bank Transfer</option> <option value="CHQ">Cheque</option> </select> </td> </tr> <tr> <td class="label">Bank Receipt #:</td> <td class="field"><input type="text" class="field" id="payment_number" name="payment_number" /></td> </tr> </table> </div> </form> <div class="popup_window_buttons_bar"> <input type="button" value="Cancel" onClick="close_payment_popup(false);" /> <input type="button" value="Confirm" onClick="close_payment_popup(true);" /> </div> </div> <div id="resend_window" class="popup_window"> <div class="popup_window_title">Resend Invoice <span id="lbl_resend_invoice"></span></div> <div class="employer_details"> <span style="font-weight: bold;">Employer: </span> <span id="employer_name"></span> <br/> <span style="font-weight: bold;">Contact Person: </span> <span id="contact_person"></span> </div> <form onSubmit="return false;"> <input type="hidden" id="resend_invoice_id" value="" /> <div class="resend_form"> <span style="font-weight: bold;">Recipients: </span>(separated by commas)<br/> <textarea id="recipients" class="recipients"></textarea> </div> </form> <div class="popup_window_buttons_bar"> <input type="button" value="Cancel" onClick="close_resend_popup(false);" /> <input type="button" value="Resend" onClick="close_resend_popup(true);" /> </div> </div> <?php }