Пример #1
0
 $body = '--yel_mail_sep_' . $invoice[0]['id'] . "\n";
 $body .= 'Content-Type: multipart/alternative; boundary="yel_mail_sep_alt_' . $invoice[0]['id'] . '"' . "\n";
 $body .= '--yel_mail_sep_alt_' . $invoice[0]['id'] . "\n";
 $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
 $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
 $mail_lines = file('../private/mail/employer_general_invoice.txt');
 $message = '';
 foreach ($mail_lines as $line) {
     $message .= $line;
 }
 $message = str_replace('%employer%', $employer->getName(), $message);
 $message = str_replace('%invoice%', pad($invoice[0]['id'], 11, '0'), $message);
 $message = str_replace('%currency%', $currency, $message);
 $message = str_replace('%amount%', $amount_payable, $message);
 $message = str_replace('%issued_on%', sql_date_format($invoice[0]['issued_on']), $message);
 $message = str_replace('%payable_by%', sql_date_format($invoice[0]['payable_by']), $message);
 $body .= $message . "\n";
 $body .= '--yel_mail_sep_alt_' . $invoice[0]['id'] . "--\n\n";
 $body .= '--yel_mail_sep_' . $invoice[0]['id'] . "\n";
 $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice[0]['id'], 11, '0') . '.pdf"' . "\n";
 $body .= 'Content-Transfer-Encoding: base64' . "\n";
 $body .= 'Content-Disposition: attachment' . "\n";
 $body .= $attachment . "\n";
 $body .= '--yel_mail_sep_' . $invoice[0]['id'] . "--\n\n";
 mail($recipients, $subject, $body, $headers);
 /*$handle = fopen('/tmp/email_to_'. $recipients. '.txt', 'w');
   fwrite($handle, 'Subject: '. $subject. "\n\n");
   fwrite($handle, $body);
   fclose($handle);*/
 @unlink($GLOBALS['data_path'] . '/general_invoices/' . $invoice[0]['id'] . '.pdf');
 echo 'ok';
Пример #2
0
            ?>
: <?php 
        }
        // end if
    }
    // end if
    echo $checkout_entry->item_record->title;
    echo $checkout_entry->item_record->{$db->field_library_copy_item_ID} > 0 ? " (Copy " . $checkout_entry->item_record->copy_number . ")" : "";
    ?>
</a><?php 
    $days_out = ceil((time() - strtotime($checkout_entry->checkout_record->out_datetime)) / 60 / 60 / 24);
    //$new_due = date("Y-m-d H:i:s", strtotime($checkout_entry->checkout_record->out_datetime) + (60 * 60 * 24 * $checkout_entry->account_record->library_overdue));
    ?>
 <span class="small"<?php 
    echo $checkout_entry->checkout_record->due_datetime < date("Y-m-d H:i:s") ? ' style="background-color:red;color:white;font-weight:bold;"' : "";
    ?>
>(<a target="_blank" href="<?php 
    echo $db->url_root;
    ?>
/checkout_edit.php/<?php 
    echo $checkout_entry->checkout_record->ID;
    ?>
">Due <?php 
    echo sql_date_format("F jS, Y", $checkout_entry->checkout_record->due_datetime);
    ?>
</a>)</span><?php 
    ?>
</div><?php 
}
// end foreach
include_once dirname(__FILE__) . "/bottom.php";
Пример #3
0
        if ($item_record->{$db->field_library_series_ID} > 0) {
            ?>
<div class="action_bar"><span class="action_heading"><?php 
            echo $series_record->title;
            echo $item_record->series_number > 0 ? " - #" . $item_record->series_number : "";
            ?>
</span></div><?php 
        }
        // end if
        if ($item_record->title != "") {
            ?>
<div class="action_bar"><span class="action_heading"><?php 
            echo $item_record->title;
            ?>
</span></div><?php 
        }
        // end if
        ?>
<div class="action_bar"><span class="action_status_success">CHECKED OUT</span></div><?php 
        ?>
<div class="action_bar"><span class="action_message">Return by <?php 
        echo sql_date_format("F jS", $due_date);
        ?>
</span></div><?php 
        ?>
<div class="action_bar break"><span class="action_instructions">Scan next item.</span></div><?php 
        include_once dirname(__FILE__) . "/kiosk_bottom.php";
        exit;
        break;
}
// end switch
Пример #4
0
 /**
  * Used to retrieve user pattern from the database
  * @param  int    $userpattern_id
  * @access public
  * @return UserPattern
  **/
 public static function get($userpattern_id)
 {
     global $cdg_sql, $err;
     $obm_q = new DB_OBM();
     $db_type = $obm_q->type;
     $timecreate = sql_date_format($db_type, "timecreate", "timecreate");
     $timeupdate = sql_date_format($db_type, "timeupdate", "timeupdate");
     // WHERE construction
     $where = array();
     $id = sql_parse_id($userpattern_id, true);
     $where[] = "id {$id}";
     //multidomain
     if (!$GLOBALS['obm']['domain_global']) {
         $domain_id = sql_parse_id($GLOBALS['obm']['domain_id'], true);
         $where[] = "(domain_id {$domain_id})";
     }
     if (!empty($where)) {
         $whereq = 'WHERE ' . implode(' AND ', $where);
     }
     // Querying
     $query = "SELECT\n        id,\n        domain_id,\n        {$timecreate},\n        {$timeupdate},\n        title,\n        description\n      FROM userpattern\n      {$whereq}";
     display_debug_msg($query, $cdg_sql, "UserPattern::get()");
     $obm_q->query($query);
     if (!$obm_q->next_record()) {
         $err['msg'] = $GLOBALS['l_id_error'];
         return false;
     }
     //else
     $pattern = new UserPattern($obm_q->f('title'), $obm_q->f('description'));
     $pattern->id = $obm_q->f('id');
     $pattern->domain_id = $obm_q->f('domain_id');
     $pattern->loadAttributes();
     return $pattern;
 }
Пример #5
0
  /**
   * getVacationToInsert 
   * 
   * @param mixed $end_time 
   * @access public
   * @return void
   */
  function getVacationToRemove($date) {
    $vacation = array();
    $obm_q = new DB_OBM;
    $db_type = $obm_q->type;
    $vacation_dateend = sql_date_format($db_type,"userobm_vacation_dateend");

    $obm_q = new DB_OBM;
    $query = "SELECT userobm_id, userobm_login, userobm_domain_id, userobm_vacation_enable FROM UserObm
      WHERE userobm_mail_perms = 1 AND userobm_vacation_dateend <= '$date' AND userobm_vacation_dateend IS NOT NULL";
    $this->logger->core($query);
    $obm_q->query($query);
    $this->logger->info($obm_q->nf()." vacations to disable");
    while($obm_q->next_record()) {
      $vacation[$obm_q->f('userobm_id')] = array("login" => $obm_q->f('userobm_login'), "domain" => $obm_q->f('userobm_domain_id'), "enable" => $obm_q->f('userobm_vacation_enable'));
    }
    $this->logger->info('List of vacation to disable : '.implode(',', array_keys($vacation)));
    return $vacation;
  }  
Пример #6
0
function send_invoice(&$_employer, $_paid_postings, $_subscription_period)
{
    if (!is_a($_employer, 'Employer')) {
        return false;
    }
    $today = date('Y-m-d');
    $branch = $_employer->getAssociatedBranch();
    $sales = 'sales.' . strtolower($branch[0]['country']) . '@yellowelevator.com';
    $branch[0]['address'] = str_replace(array("\r\n", "\r"), "\n", $branch[0]['address']);
    $branch['address_lines'] = explode("\n", $branch[0]['address']);
    $currency = Currency::getSymbolFromCountryCode($branch[0]['country']);
    if ($_paid_postings > 0) {
        // 0. get the job postings pricing and currency
        $posting_rates = $GLOBALS['postings_rates'];
        $price = $posting_rates[$currency];
        // 1. generate invoice in the system
        $data = array();
        $data['issued_on'] = $today;
        $data['type'] = 'P';
        $data['employer'] = $_POST['id'];
        $data['payable_by'] = sql_date_add($today, $_employer->getPaymentTermsInDays(), 'day');
        $invoice = Invoice::create($data);
        if ($invoice === false) {
            echo 'ko';
            exit;
        }
        $amount = $price * $_paid_postings;
        $desc = $_paid_postings . ' Job Posting(s) @ ' . $currency . ' $' . $price;
        $item_added = Invoice::addItem($invoice, $amount, '1', $desc);
        $items = array();
        $items[0]['itemdesc'] = $desc;
        $items[0]['amount'] = number_format($amount, '2', '.', ', ');
        // 2. generate the invoice as PDF file
        $pdf = new PaidPostingsInvoice();
        $pdf->AliasNbPages();
        $pdf->SetAuthor('Yellow Elevator. This invoice was automatically generated. Signature is not required.');
        $pdf->SetTitle($GLOBALS['COMPANYNAME'] . ' - Invoice ' . pad($invoice, 11, '0'));
        $pdf->SetCurrency($currency);
        $pdf->SetBranch($branch);
        $pdf->AddPage();
        $pdf->SetFont('Arial', '', 10);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->SetFillColor(54, 54, 54);
        $pdf->Cell(60, 5, "Invoice Number", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Issuance Date", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Payable By", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Amount Payable (" . $currency . ")", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, pad($invoice, 11, '0'), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['issued_on']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['payable_by']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, number_format($amount, '2', '.', ', '), 1, 0, 'C');
        $pdf->Ln(6);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->Cell(60, 5, "User ID", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Employer Name", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, $_employer->getId(), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, $_employer->getName(), 1, 0, 'C');
        $pdf->Ln(10);
        $table_header = array("No.", "Item", "Amount (" . $currency . ")");
        $pdf->FancyTable($table_header, $items, number_format($amount, '2', '.', ', '));
        $pdf->Ln(13);
        $pdf->SetFont('', 'I');
        $pdf->Cell(0, 0, "This invoice was automatically generated. Signature is not required.", 0, 0, 'C');
        $pdf->Ln(6);
        $pdf->Cell(0, 5, "Payment Notice", 'LTR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- Payment shall be made payable to " . $branch[0]['branch'] . ".", 'LR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- To facilitate the processing of the payment, please write down the invoice number(s) on your cheque(s)/payment slip(s)", 'LBR', 0, 'C');
        $pdf->Ln(10);
        $pdf->Cell(0, 0, "E. & O. E.", 0, 0, 'C');
        $pdf->Close();
        $pdf->Output($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf', 'F');
        // 3. sends it as an email
        $attachment = chunk_split(base64_encode(file_get_contents($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf')));
        $subject = "Subscription Invoice " . pad($invoice, 11, '0');
        $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n";
        $headers .= 'Bcc: ' . $sales . "\n";
        $headers .= 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-Type: multipart/mixed; boundary="yel_mail_sep_' . $invoice . '";' . "\n\n";
        $body = '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: multipart/alternative; boundary="yel_mail_sep_alt_' . $invoice . '"' . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "\n";
        $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
        $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
        $mail_lines = file('../private/mail/employer_posting_invoice.txt');
        $message = '';
        foreach ($mail_lines as $line) {
            $message .= $line;
        }
        $message = str_replace('%employer%', $_employer->getName(), $message);
        $message = str_replace('%postings%', $_POST['paid_postings'], $message);
        $message = str_replace('%price%', $price, $message);
        $message = str_replace('%currency%', $currency, $message);
        $message = str_replace('%amount%', number_format($amount, 2, '.', ', '), $message);
        $issued_date = explode('-', $data['issued_on']);
        $issued_timestamp = $issued_date[0] . $issued_date[1] . $issued_date[2];
        $message = str_replace('%purchased_on%', date('j M', $issued_timestamp) . ', ' . $issued_date[0], $message);
        $body .= $message . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "--\n\n";
        $body .= '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice, 11, '0') . '.pdf"' . "\n";
        $body .= 'Content-Transfer-Encoding: base64' . "\n";
        $body .= 'Content-Disposition: attachment' . "\n";
        $body .= $attachment . "\n";
        $body .= '--yel_mail_sep_' . $invoice . "--\n\n";
        mail($_employer->getEmailAddress(), $subject, $body, $headers);
        // $handle = fopen('/tmp/email_to_'. $_employer->getEmailAddress(). '.txt', 'w');
        // fwrite($handle, 'Subject: '. $subject. "\n\n");
        // fwrite($handle, $body);
        // fclose($handle);
        unlink($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf');
    }
    if ($_subscription_period > 0) {
        $single_subscription_prices = array('MYR' => 1000, 'SGD' => 1000);
        // 0. get the job postings pricing and currency
        $subscriptions_rates = $GLOBALS['subscriptions_rates'];
        $amount = $subscriptions_rates[$currency][$_subscription_period];
        if ($_subscription_period == 1) {
            $amount = $single_subscription_prices[$currency];
        }
        $admin_fee = 0.05 * $amount;
        $total = $admin_fee + $amount;
        // 1. generate invoice in the system
        $data = array();
        $data['issued_on'] = $today;
        $data['type'] = 'J';
        $data['employer'] = $_employer->getId();
        $data['payable_by'] = sql_date_add($today, $_employer->getPaymentTermsInDays(), 'day');
        $invoice = Invoice::create($data);
        if ($invoice === false) {
            echo 'ko';
            exit;
        }
        $desc = $_subscription_period . ' month(s) of subscription';
        $item_added = Invoice::addItem($invoice, $total, '1', $desc);
        $items = array();
        $items[0]['itemdesc'] = $desc;
        $items[0]['amount'] = number_format($amount, '2', '.', ', ');
        $items[1]['itemdesc'] = 'Administration Fee';
        $items[1]['amount'] = number_format($admin_fee, '2', '.', ', ');
        // 2. generate the PDF version to be attached to sales.xx and the employer
        $pdf = new SubscriptionInvoice();
        $pdf->AliasNbPages();
        $pdf->SetAuthor('Yellow Elevator. This invoice was automatically generated. Signature is not required.');
        $pdf->SetTitle($GLOBALS['COMPANYNAME'] . ' - Invoice ' . pad($invoice, 11, '0'));
        $pdf->SetCurrency($currency);
        $pdf->SetBranch($branch);
        $pdf->AddPage();
        $pdf->SetFont('Arial', '', 10);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->SetFillColor(54, 54, 54);
        $pdf->Cell(60, 5, "Invoice Number", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Issuance Date", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Payable By", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Amount Payable (" . $currency . ")", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, pad($invoice, 11, '0'), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['issued_on']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['payable_by']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, number_format($total, '2', '.', ', '), 1, 0, 'C');
        $pdf->Ln(6);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->Cell(60, 5, "User ID", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Employer Name", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, $_employer->getId(), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, $_employer->getName(), 1, 0, 'C');
        $pdf->Ln(10);
        $table_header = array("No.", "Item", "Amount (" . $currency . ")");
        $pdf->FancyTable($table_header, $items, number_format($total, '2', '.', ', '));
        $pdf->Ln(13);
        $pdf->SetFont('', 'I');
        $pdf->Cell(0, 0, "This invoice was automatically generated. Signature is not required.", 0, 0, 'C');
        $pdf->Ln(6);
        $pdf->Cell(0, 5, "Payment Notice", 'LTR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- Payment shall be made payable to " . $branch[0]['branch'] . ".", 'LR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- To facilitate the processing of the payment, please write down the invoice number(s) on your cheque(s)/payment slip(s)", 'LBR', 0, 'C');
        $pdf->Ln(10);
        $pdf->Cell(0, 0, "E. & O. E.", 0, 0, 'C');
        $pdf->Close();
        $pdf->Output($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf', 'F');
        // 3. attach it to email
        $attachment = chunk_split(base64_encode(file_get_contents($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf')));
        $subject = "Subscription Invoice " . pad($invoice, 11, '0');
        $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n";
        $headers .= 'Bcc: ' . $sales . "\n";
        $headers .= 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-Type: multipart/mixed; boundary="yel_mail_sep_' . $invoice . '";' . "\n\n";
        $body = '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: multipart/alternative; boundary="yel_mail_sep_alt_' . $invoice . '"' . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "\n";
        $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
        $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
        $mail_lines = file('../private/mail/employer_subscription_invoice.txt');
        $message = '';
        foreach ($mail_lines as $line) {
            $message .= $line;
        }
        $message = str_replace('%employer%', $_employer->getName(), $message);
        $message = str_replace('%period%', $_subscription_period, $message);
        $message = str_replace('%currency%', $currency, $message);
        $message = str_replace('%amount%', number_format($total, 2, '.', ', '), $message);
        $issued_date = explode('-', $data['issued_on']);
        $issued_timestamp = $issued_date[0] . $issued_date[1] . $issued_date[2];
        $message = str_replace('%purchased_on%', date('j M', $issued_timestamp) . ', ' . $issued_date[0], $message);
        $body .= $message . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "--\n\n";
        $body .= '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice, 11, '0') . '.pdf"' . "\n";
        $body .= 'Content-Transfer-Encoding: base64' . "\n";
        $body .= 'Content-Disposition: attachment' . "\n";
        $body .= $attachment . "\n";
        $body .= '--yel_mail_sep_' . $invoice . "--\n\n";
        mail($_employer->getEmailAddress(), $subject, $body, $headers);
        /*$handle = fopen('/tmp/email_to_'. $_employer->getEmailAddress(). '.txt', 'w');
          fwrite($handle, 'Subject: '. $subject. "\n\n");
          fwrite($handle, $body);
          fclose($handle);*/
        unlink($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf');
    }
    return true;
}
Пример #7
0
        ?>
</div>
		<?php 
    }
    // end if
}
// end if
?>
<table cellspacing="0" cellpadding"0" border="0" width="100%">
	<tr>
		<td valign="top" width="0%">
			<?php 
if ($record->lost_datetime != $db->blank_datetime && $record->in_datetime != $db->blank_datetime) {
    ?>
					<div class="detail_status_lost" title="on <?php 
    echo sql_date_format("F jS, Y", $record->lost_datetime);
    if ($record->{$db->field_lost_account_ID} > 0) {
        if ($lost_account_record = lookup_account($record->{$db->field_lost_account_ID})) {
            ?>
 by <?php 
            echo $lost_account_record->name;
        }
        // end if
    }
    // end if
    ?>
">
						Lost
					</div>
					<?php 
} else {
Пример #8
0
function output_letter($account_ID)
{
    global $db, $mysql, $pm, $accounts, $first_page;
    $account_sql = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`" . $db->table_account . "`\n\t\tWHERE\n\t\t\t`ID`='" . mysql_escape_string($account_ID) . "'\n\t";
    $account_result = mysql_query($account_sql, $mysql->link);
    $account_record = mysql_fetch_object($account_result);
    $checkout_records = array();
    $lost_records = array();
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////// LOOKUP OVERDUE RECORDS
    $checkout_sql = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`" . $db->table_library_checkout . "`\n\t\tWHERE\n\t\t\t`" . $db->field_account_ID . "`='" . mysql_escape_string($account_ID) . "'\n\t\t\tAND `out_datetime`!='" . $db->blank_datetime . "'\n\t\t\tAND `in_datetime`='" . $db->blank_datetime . "'\n\t\t\tAND `lost_datetime`='" . $db->blank_datetime . "'\n\t";
    $checkout_result = mysql_query($checkout_sql, $mysql->link);
    if (mysql_num_rows($checkout_result) > 0) {
        while ($checkout_record = mysql_fetch_object($checkout_result)) {
            if ($checkout_record->due_datetime < date("Y-m-d H:i:s")) {
                $checkout_records[] = $checkout_record;
                $overdue_item_count++;
            }
            // end if
        }
        // end while
    }
    // end if
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////// LOOKUP LOST RECORDS
    $lost_sql = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`" . $db->table_library_checkout . "`\n\t\tWHERE\n\t\t\t`" . $db->field_account_ID . "`='" . mysql_escape_string($account_ID) . "'\n\t\t\tAND `out_datetime`!='" . $db->blank_datetime . "'\n\t\t\tAND `lost_datetime`!='" . $db->blank_datetime . "'\n\t\t\tAND `in_datetime`='" . $db->blank_datetime . "'\n\t\t\tAND `paid_datetime`='" . $db->blank_datetime . "'\n\t";
    $lost_result = mysql_query($lost_sql, $mysql->link);
    if (mysql_num_rows($lost_result) > 0) {
        while ($lost_record = mysql_fetch_object($lost_result)) {
            $lost_records[] = $lost_record;
            $lost_item_count++;
        }
        // end while
    }
    // end if
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////// CREATE LETTER
    if ($overdue_item_count + $lost_item_count > 0) {
        if (!$first_page) {
            $pm->new_page();
        }
        // end if
        $first_page = FALSE;
        $current_number = $starting_number;
        require_once $db->include_dir . "/fonts/times.php";
        include_once $db->include_dir . "/pdf_maker.php";
        $xo = 1;
        $yo = 1;
        $lw = 6.5;
        $lh = 9;
        $pm->set_font("times");
        $text = "Immanuel Mission School\n" . date("F jS, Y") . "\n\n\n" . ($account_record->library_notices_to == "P" ? "Dear Parent/Guardian" : $account_record->name) . ",\n\n";
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////// OVERDUE ITEM LIST
        if ($overdue_item_count > 0) {
            $text .= "We want you to know that " . ($account_record->library_notices_to == "P" ? $account_record->name . " has" : "you have") . " " . $overdue_item_count . " item" . ($overdue_item_count != 1 ? "s" : "") . " checked-out from our library that need" . ($overdue_item_count != 1 ? "" : "s") . " to be returned.  The " . ($overdue_item_count != 1 ? "information about the items are" : "item information is") . " listed below.\n\n";
            foreach ($checkout_records as $checkout_record) {
                $item_sql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`" . $db->table_library_item . "`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`ID`='" . $checkout_record->item_ID . "'\n\t\t\t\t";
                $item_result = mysql_query($item_sql, $mysql->link);
                $item_record = mysql_fetch_object($item_result);
                $text .= "     ";
                if ($item_record->{$db->field_library_series_ID} != 0) {
                    $series_sql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`" . $db->table_series . "`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`ID`='" . $item_record->{$db->field_library_series_ID} . "'\n\t\t\t\t\t";
                    $series_result = mysql_query($series_sql, $mysql->link);
                    $series_record = mysql_fetch_object($series_result);
                    $text .= $series_record->title;
                    if ($item_record->series_number > 0) {
                        $text .= " #" . $item_record->series_number;
                    }
                    // end if
                    $text .= ": ";
                }
                // end if
                $text .= $item_record->title;
                if ($item_record->{$db->field_library_type_ID} != $db->ID_type_book) {
                    $type_sql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`" . $db->table_library_type . "`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`ID`='" . $item_record->{$db->field_library_type_ID} . "'\n\t\t\t\t\t";
                    $type_result = mysql_query($type_sql, $mysql->link);
                    $type_record = mysql_fetch_object($type_result);
                    $text .= " (" . $type_record->title . ")";
                }
                // end if
                $text .= "  (out since " . sql_date_format("F jS, Y", $checkout_record->out_datetime) . ")\n\n";
            }
            // end foreach
            if ($lost_item_count < 1) {
                $text .= "Please find and return " . ($overdue_item_count != 1 ? "these items" : "this item") . " as soon as possible.\n\n";
            }
            // end if
        }
        // end if
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////// LOST ITEM LIST
        if ($lost_item_count > 0) {
            $total_due = 0;
            if ($overdue_item_count > 0) {
                $text .= "You also should know that there " . ($lost_item_count != 1 ? "are" : "is") . " " . $lost_item_count . " item" . ($lost_item_count != 1 ? "s" : "") . " that " . ($lost_item_count != 1 ? "have" : "has") . " been lost and need" . ($lost_item_count != 1 ? "" : "s") . " to be paid for.";
            } else {
                $text .= "We want you to know that " . ($account_record->library_notices_to == "P" ? $account_record->name . " has" : "you have") . " " . $lost_item_count . " item" . ($lost_item_count != 1 ? "s" : "") . " that " . ($lost_item_count != 1 ? "have" : "has") . " been lost and need" . ($lost_item_count != 1 ? "" : "s") . " to be paid for.";
            }
            // end if
            $text .= "  The " . ($lost_item_count != 1 ? "information about the items are" : "item information is") . " listed below.\n\n";
            foreach ($lost_records as $lost_record) {
                $item_sql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`" . $db->table_library_item . "`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`ID`='" . $lost_record->item_ID . "'\n\t\t\t\t";
                $item_result = mysql_query($item_sql, $mysql->link);
                $item_record = mysql_fetch_object($item_result);
                $text .= "     " . $item_record->title;
                if ($item_record->{$db->field_library_type_ID} != $db->ID_type_book) {
                    $type_sql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`" . $db->table_library_type . "`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`ID`='" . $item_record->{$db->field_library_type_ID} . "'\n\t\t\t\t\t";
                    $type_result = mysql_query($type_sql, $mysql->link);
                    $type_record = mysql_fetch_object($type_result);
                    $text .= " (" . $type_record->title . ")";
                }
                // end if
                $text .= "  (reported lost on " . sql_date_format("F jS, Y", $lost_record->lost_datetime) . ")\n          Replacement fee: \$" . $lost_record->lost_fee . "\n\n";
                $total_due += $lost_record->lost_fee;
            }
            // end foreach
            if ($overdue_item_count < 1) {
                $text .= "Please pay for " . ($lost_item_count != 1 ? "these items" : "this item") . " as soon as possible.";
            } else {
                $text .= "Please find and return the overdue item" . ($overdue_item_count != 1 ? "s" : "") . " and pay for the lost item" . ($lost_item_count != 1 ? "s" : "") . " as soon as possible.";
            }
            // end if
            if ($lost_item_count > 1) {
                $text .= "  The total amount due for the lost items is: \$" . $total_due . "\n\n";
            } else {
                $text .= "\n\n";
            }
            // end if
        }
        // end if
        $text .= "\nThank you,\n" . $accounts->account_record->name . "\n";
        $pm->text_wrap($xo, $yo, 0.21, $text, $lw, $align = "left");
    }
    // end if
}
Пример #9
0
    $pdf->Cell(33, 5, "Payable By", 1, 0, 'C', 1);
} else {
    $pdf->Cell(33, 5, "Paid On", 1, 0, 'C', 1);
}
$pdf->Cell(1);
$pdf->Cell(0, 5, "Amount Payable (" . $currency . ")", 1, 0, 'C', 1);
$pdf->Ln(6);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(60, 5, pad($_GET['id'], 11, '0'), 1, 0, 'C');
$pdf->Cell(1);
$pdf->Cell(33, 5, sql_date_format($invoice[0]['issued_on']), 1, 0, 'C');
$pdf->Cell(1);
if (is_null($invoice[0]['paid_on']) || empty($invoice[0]['paid_on'])) {
    $pdf->Cell(33, 5, sql_date_format($invoice[0]['payable_by']), 1, 0, 'C');
} else {
    $pdf->Cell(33, 5, sql_date_format($invoice[0]['paid_on']), 1, 0, 'C');
}
$pdf->Cell(1);
$pdf->Cell(0, 5, $amount_payable, 1, 0, 'C');
$pdf->Ln(6);
$pdf->SetTextColor(255, 255, 255);
$pdf->Cell(60, 5, "User ID", 1, 0, 'C', 1);
$pdf->Cell(1);
$pdf->Cell(0, 5, "Employer Name", 1, 0, 'C', 1);
$pdf->Ln(6);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(60, 5, $invoice[0]['employer'], 1, 0, 'C');
$pdf->Cell(1);
$pdf->Cell(0, 5, $employer->getName(), 1, 0, 'C');
$pdf->Ln(10);
$table_header = array("No.", "Item", "Amount (" . $currency . ")");