Esempio n. 1
0
 function getBillingOnly($regisID = 0)
 {
     header('Content-type: text/html; charset=utf-8');
     $amount = 0;
     $this->load->model('register/user_m', 'user_m');
     $this->load->model('register/course_m', 'course_m');
     $res = $this->user_m->getBillingInfo($regisID);
     $data = array();
     $data = $res[0];
     //print_r($data);
     $regisBy = 0;
     if ((int) $data['registerBy'] == 3) {
         $representive = $this->user_m->getRepresentive($regisID);
         $price = (double) $data['price'];
         $sum_rep = count($representive);
         $amount = (double) ($price * $sum_rep);
         $data['sum_register'] = $sum_rep;
         $regisBy = 3;
     } else {
         $amount = (double) $data['price'];
         $data['sum_register'] = '1';
         $regisBy = 0;
     }
     $price_format = (double) $data['price'];
     $data['amount'] = number_format($amount, 2);
     $data['price_format'] = number_format($price_format, 2);
     $data['txt_price'] = util::num2thai($amount);
     if (intval($regisID) > 9999) {
         $refNo = $this->user_m->getRefInfo($regisID);
         $data['ref1'] = $refNo[0]['billing_ref1'];
         $data['ref2'] = $refNo[0]['billing_ref2'];
     } else {
         $data['ref1'] = str_pad($data['traineeID'], 4, '0', STR_PAD_LEFT);
         $data['ref2'] = substr($data['coursecode'], 2, 3) . substr($data['generation'], 0, 1) . str_pad($data['registrationID'], 4, '0', STR_PAD_LEFT);
     }
     //        $refInfo =$this->user_m->getRefInfo($regisID);
     //        $data['ref2'] = $refInfo[0]['billing_ref2'];
     //        $data['ref1'] = $refInfo[0]['billing_ref1'];
     $regDate = date('Y-m-d', strtotime($data['registerdatetime']));
     $separateRegDate = explode("-", $regDate);
     $regDate = date('Y-m-d', strtotime($regDate . " +15 days"));
     $nowDate = date('Y-m-d');
     $txt_end_pay = "กรุณาชำระเงินภายใน  15 วัน";
     if (strtotime($regDate) <= strtotime($nowDate)) {
         $txt_end_pay = "วันสุดท้ายในการชำระเงิน " . Thaidate::date($data["payenddate"], "DD MM YYYY");
     } else {
         $txt_end_pay = "วันสุดท้ายในการชำระเงิน " . Thaidate::date($regDate . ' 00:00:00', "DD MM YYYY");
     }
     $content = file_get_contents('template_email/bill.html');
     $content = str_replace('<!--date-->', date('d/m/Y'), $content);
     $content = str_replace('<!--txt_end_pay-->', $txt_end_pay, $content);
     $content = str_replace('<!--company_id-->', $data['hospitalID'], $content);
     $content = str_replace('<!--name-->', $data['name'] . ' ' . $data['lastname'], $content);
     //$content = str_replace('<!--name-->', $data['receipt_name'], $content);
     $content = str_replace('<!--ref1-->', $data['ref1'], $content);
     $content = str_replace('<!--ref2-->', $data['ref2'], $content);
     $content = str_replace('<!--amount-->', $data['amount'], $content);
     $content = str_replace('<!--txt_price-->', $data['txt_price'], $content);
     $content = str_replace('<!--sum_register-->', $data['sum_register'], $content);
     $content = str_replace('<!--period-->', Thaidate::date($data['startdate'], 'DD MM YYYY') . ' - ' . Thaidate::date($data['enddate'], 'DD MM YYYY'), $content);
     $content = str_replace('<!--place-->', $data['place'], $content);
     $content = str_replace('<!--course_name-->', $data['coursename'] . '(' . $data['coursecode'] . ')', $content);
     $content = str_replace('<!--course_day-->', $data['days'], $content);
     $content = str_replace('<!--price-->', $data['price_format'], $content);
     $content = str_replace('<!--dd-->', (int) $separateRegDate[2], $content);
     $content = str_replace('<!--mm-->', Thaidate::thaiMonth((int) $separateRegDate[1]), $content);
     $content = str_replace('<!--yy-->', (int) $separateRegDate[0] + 543, $content);
     $content = str_replace('<!--billing_address-->', $this->getBillingAddress($regisID, $regisBy), $content);
     $resCourse = $this->course_m->getCourse($data['courseID']);
     //TODO SET COMPANY CODE
     $courseType = $resCourse[0]['coursetypeID'];
     $companycode = '90122';
     if ($courseType == 2) {
         $companycode = '90122';
     } else {
         $companycode = '9968';
     }
     $content = str_replace('<!--companycode-->', $companycode, $content);
     return $content;
 }
Esempio n. 2
0
 function getBilling($regisID = 0)
 {
     header('Content-type: text/html; charset=utf-8');
     $amount = 0;
     $this->load->model('register/user_m', 'user_m');
     $res = $this->user_m->getBillingInfo($regisID);
     $data = array();
     $data = $res[0];
     if ((int) $data['registerBy'] == 3) {
         $representive = $this->user_m->getRepresentive($regisID);
         $price = (double) $data['price'];
         $sum_rep = count($representive);
         $amount = (double) ($price * $sum_rep);
         $data['sum_register'] = $sum_rep;
     } else {
         $amount = (double) $data['price'];
         $data['sum_register'] = '1';
     }
     $price_format = (double) $data['price'];
     $data['amount'] = number_format($amount, 2);
     $data['price_format'] = number_format($price_format, 2);
     $data['txt_price'] = util::num2thai($amount);
     //$data['ref1'] = '1' . str_pad($data['traineeID'], 5, '0', STR_PAD_LEFT);
     $data['ref1'] = str_pad($data['traineeID'], 5, '0', STR_PAD_LEFT);
     $date = explode(' ', $data['startdate']);
     $date = explode('-', $date[0]);
     $month = $date[1];
     $year = (int) $date[0] + 543;
     //$data['ref2'] = substr($data['coursecode'], 2, 3) . substr($data['generation'], 0, 1) . $month . substr($year, 2, 2) . str_pad($data['registrationID'], 4, '0', STR_PAD_LEFT);
     $data['ref2'] = substr($data['coursecode'], 2, 3) . substr($data['generation'], 0, 1) . str_pad($data['registrationID'], 5, '0', STR_PAD_LEFT);
     // var_dump($data);
     //  exit;
     $content = file_get_contents('template_email/bill.html');
     $content = str_replace('<!--date-->', date('d/m/Y'), $content);
     $content = str_replace('<!--company_id-->', $data['hospitalID'], $content);
     //$content = str_replace('<!--name-->', $data['name'] . ' ' . $data['lastname'], $content);
     $content = str_replace('<!--name-->', $data['receipt_name'], $content);
     $content = str_replace('<!--ref1-->', $data['ref1'], $content);
     $content = str_replace('<!--ref2-->', $data['ref2'], $content);
     $content = str_replace('<!--amount-->', $data['amount'], $content);
     $content = str_replace('<!--txt_price-->', $data['txt_price'], $content);
     $content = str_replace('<!--sum_register-->', $data['sum_register'], $content);
     $content = str_replace('<!--period-->', Thaidate::date($data['startdate'], 'DD MM YYYY') . ' - ' . Thaidate::date($data['enddate'], 'DD MM YYYY'), $content);
     $content = str_replace('<!--place-->', $data['place'], $content);
     $content = str_replace('<!--course_name-->', $data['coursename'] . '(' . $data['coursecode'] . ')', $content);
     $content = str_replace('<!--course_day-->', $data['days'], $content);
     $content = str_replace('<!--price-->', $data['price_format'], $content);
     $content = str_replace('<!--dd-->', date('d'), $content);
     $content = str_replace('<!--mm-->', Thaidate::thaiMonth(date('n')), $content);
     $content = str_replace('<!--yy-->', (int) date('Y') + 543, $content);
     // update ref no.
     $this->user_m->updateRegistrationRefNo($data['registrationID'], $data['ref1'], $data['ref2']);
     return $content;
 }