Ejemplo n.º 1
0
 /**
  * Add a job posting to the database.
  * @param	string	job title
  * @param	string	description
  * @param	Array	categories id
  * @param   int     1 if public; 0 otherwise.
  * @param   string  Closing date for this job post, mysql TIMESTAMP format
  * @precondition	ATutor Mailer class imported.
  */
 function addJob($title, $description, $categories, $is_public, $closing_date)
 {
     require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php';
     global $addslashes, $db, $msg, $_config, $_base_href;
     if ($_SESSION['jb_employer_id'] < 1) {
         $msg->addError();
         //authentication error
         exit;
     } else {
         include AT_JB_INCLUDE . 'Employer.class.php';
         $employer = new Employer($_SESSION['jb_employer_id']);
         $employer_id = $employer->getId();
     }
     $title = $addslashes($title);
     $description = $addslashes($description);
     $is_public = isset($is_public) ? 1 : 0;
     $closing_date = $addslashes($closing_date);
     $approval_state = $_config['jb_posting_approval'] == 1 ? AT_JB_POSTING_STATUS_UNCONFIRMED : AT_JB_POSTING_STATUS_CONFIRMED;
     $sql = 'INSERT INTO ' . TABLE_PREFIX . "jb_postings (employer_id, title, description, is_public, closing_date, created_date, revised_date, approval_state) VALUES ({$employer_id}, '{$title}', '{$description}', {$is_public}, '{$closing_date}', NOW(), NOW(), {$approval_state})";
     $result = mysql_query($sql, $db);
     $posting_id = mysql_insert_id();
     //add to posting category table
     if (!empty($categories)) {
         foreach ($categories as $id => $category) {
             $category = intval($category);
             $sql = 'INSERT INTO ' . TABLE_PREFIX . "jb_posting_categories (posting_id, category_id) VALUES ({$posting_id}, {$category})";
             mysql_query($sql, $db);
             //send out notification if the person is subscribed to the category.
             $sql = 'SELECT m.member_id, m.email FROM ' . TABLE_PREFIX . 'jb_category_subscribes cs LEFT JOIN ' . TABLE_PREFIX . "members m ON cs.member_id=m.member_id WHERE category_id={$category}";
             $result = mysql_query($sql, $db);
             $post_link = $_base_href . AT_JB_BASENAME . 'view_post.php?jid=' . $posting_id;
             if ($result) {
                 while ($row = mysql_fetch_assoc($result)) {
                     $mail = new ATutorMailer();
                     $mail->AddAddress($row['email'], get_display_name($row['member_id']));
                     $body = _AT('jb_subscription_msg', $title, $this->getCategoryNameById($category), $post_link);
                     $body .= "\n\n";
                     $body .= _AT('jb_posted_by') . ": " . htmlentities_utf8($employer->getCompany()) . "\n";
                     $mail->FromName = $_config['site_name'];
                     $mail->From = $_config['contact_email'];
                     $mail->Subject = _AT('jb_subscription_mail_subject');
                     $mail->Body = $body;
                     if (!$mail->Send()) {
                         $msg->addError('SENDING_ERROR');
                     }
                     unset($mail);
                 }
             }
         }
     }
     if (!$result) {
         //TODO: db error message
         $msg->addError();
     }
 }
Ejemplo n.º 2
0
        // fwrite($handle, 'Subject: '. $subject. "\n\n");
        // fwrite($handle, $message);
        // fclose($handle);
    }
    echo 'ok';
    exit;
}
if ($_POST['action'] == 'copy_fees') {
    $from_employer = new Employer($_POST['employer']);
    $to_employer = new Employer($_POST['id']);
    $fees = $from_employer->getFees();
    if ($to_employer->createFees($fees) === false) {
        echo 'ko';
        exit;
    }
    $criteria = array('columns' => "working_months, payment_terms_days", 'match' => "id = '" . $from_employer->getId() . "'", 'limit' => "1");
    $result = $from_employer->find($criteria);
    $data = array();
    $data['working_months'] = $result[0]['working_months'];
    $data['payment_terms_days'] = $result[0]['payment_terms_days'];
    $to_employer->update($data);
    echo 'ok';
    exit;
}
if ($_POST['action'] == 'delete_fee') {
    $employer = new Employer();
    if ($employer->deleteFee($_POST['id']) === false) {
        echo 'ko';
        exit;
    }
    echo 'ok';
Ejemplo n.º 3
0
     // 2.2.1c If the difference in fees is more than zero, then use the amount difference.
     if (round($amount_difference, 2) <= 0) {
         $subtotal = $discount = $extra_charges = 0.0;
         $is_free_replacement = true;
         $credit_amount = abs($amount_difference);
     } else {
         $discount = $extra_charges = 0.0;
         $subtotal = $amount_difference;
     }
 }
 // 2.3 Generate the invoice
 $issued_on = date('j M, Y');
 $data = array();
 $data['issued_on'] = now();
 $data['type'] = 'R';
 $data['employer'] = $employer->getId();
 $data['payable_by'] = sql_date_add($data['issued_on'], $payment_terms_days, 'day');
 if ($is_free_replacement) {
     $data['paid_on'] = $data['issued_on'];
     $data['paid_through'] = 'CSH';
     $data['paid_id'] = 'FREE_REPLACEMENT';
 }
 $invoice = Invoice::create($data);
 if (!$invoice) {
     echo 'ko';
     exit;
 }
 $referral_desc = 'Reference fee for [' . $job['id'] . '] ' . $job['title'] . ' of ' . $candidate->getFullName();
 if ($is_free_replacement) {
     $referral_desc = 'Free replacement for Invoice: ' . pad($previous_invoice, 11, '0');
 }