Exemplo n.º 1
0
 public function updateCalendarTeach_post()
 {
     $data = $this->post();
     if ($data && is_array($data)) {
         $this->load->model("m_calendar_teach");
         if ($info_calendar = $this->m_calendar_teach->get_one(array('calendar_code' => $data['calendar_code']))) {
             $data_update_calendar = array('calendar_code' => isset($data['calendar_code']) ? $data['calendar_code'] : '', 'teacher_id' => isset($data['teacher_id']) ? $data['teacher_id'] : '', 'assistant_id' => isset($data['assistant_id']) ? $data['assistant_id'] : '', 'flag' => 1);
             if (isset($data['status'])) {
                 //xoa lop
                 $this->m_calendar_teach->update($info_calendar->id, array('status' => 0));
             } else {
                 //cap nhat thong tin lop
                 $this->m_calendar_teach->update($info_calendar->id, $data_update_calendar);
             }
             $this->load->model('m_rest_client_lms');
             $rest_add_calendarteach = Rest_Client_Factory::create('add_calendarteachs');
             $params = json_encode(array($data));
             $rest_add_calendarteach->add_param('data_calendar', $params);
             $result = $rest_add_calendarteach->send();
             if (!$result || $result && isset($result->exception)) {
                 if ($result) {
                     $response = array('status' => FALSE, 'msg' => $result->message . " - " . isset($result->debuginfo) ? $result->debuginfo : '');
                 } else {
                     $response = array('status' => FALSE, 'msg' => 'Không kết nối được API');
                 }
             }
             if (isset($result->data) && count($result->data)) {
                 foreach ($result->data as $item) {
                     $data_update['flag'] = 2;
                     $this->m_calendar_teach->update(array('calendar_code' => $item), $data_update);
                 }
                 $response = array('status' => true, 'msg' => 'đã thêm bản ghi thành công');
             } else {
                 $response = array('status' => FALSE, 'msg' => 'Không có dữ liệu trả về');
             }
         } else {
             $response = array('status' => FALSE, 'msg' => 'Không có dữ liệu gửi lên');
         }
         $this->response($response);
     }
 }
Exemplo n.º 2
0
 function test_add_user()
 {
     $this->load->model("m_rest_client_lms");
     $rest_adduseronly = Rest_Client_Factory::create('add_user');
     $rest_adduseronly->add_params(array('users' => array(array('username' => 'thieulm', 'firstname' => 'thieu', 'lastname' => 'thieu', 'email' => '*****@*****.**', 'phone1' => '0123456789', 'password' => 'topica123', 'lang' => 'vi', 'customfields' => array(array('type' => 'contactid', 'value' => '11023293291923'), array('type' => 'currentlevel', 'value' => 'basic'), array('type' => 'package', 'value' => 0), array('type' => 'packageparent', 'value' => 'TAAM'), array('type' => 'studenttype', 'value' => 'AUTOSALE')))), 'enrol' => array('timestart' => time(), 'timeend' => 0, 'courseid' => 2, 'role' => 'student')));
     $result_add_user = $rest_adduseronly->send();
     echo "<pre>";
     var_dump($result_add_user);
     exit;
     if ($result_add_user && isset($result_add_user->exception)) {
         $debug = '';
         $debug = isset($result_add_user->debuginfo) ? $result_add_user->debuginfo : '';
         $data_return["state"] = 0;
         $data_return["msg"] = $result_add_user->message . ' - ' . $debug;
         $data_return["redirect"] = "";
         echo json_encode($data_return);
         return FALSE;
     } else {
         if ($result_add_user == NULL) {
             $data_return["state"] = 0;
             $data_return["msg"] = "Chết API, chưa tạo được tài khoản";
             $data_return["redirect"] = "";
             echo json_encode($data_return);
             return FALSE;
         }
     }
 }
Exemplo n.º 3
0
 public function add_class()
 {
     $this->load->model("m_rest_client_lms");
     $this->load->model("m_contact_submit");
     $rest_add_calendarteach = Rest_Client_Factory::create('local_update_calendarteachs');
     $list_class = $this->m_contact_submit->get_list(array('m.payment !=' => '', 'm.status_create_class !=' => 1));
     $info_calendar = array();
     $arr_subject_code = array('9' => 'AT01', '10' => 'AT04', '15' => 'AT03', '16' => 'AT05', '19' => 'AT01', '20' => 'AT02', '21' => 'AT03', '23' => 'AT04', '22' => 'AT05', 'SBASIC' => 'AT06');
     foreach ($list_class as $key => $item) {
         // $subject_code = array_rand($arr_subject_code,1);
         $temp = array('submit_id' => $item->id, 'week' => date('W', strtotime($item->date)), 'year' => date('o', strtotime($item->date)), 'week_day' => strtoupper(date('l', strtotime($item->date))), 'hour_id' => intval($item->time) - 7, 'level_class' => 'basic', 'teacher_type' => 'AM', 'type_class' => 'LS', 'contact_id' => $item->contact_id, 'name' => $arr_subject_code[intval($item->time)] . ' - ' . $item->name, 'student_type' => 'TL');
         if (trim($item->level) == 'Chưa nghe nói được') {
             // $temp['subject_code'] = $arr_subject_code['SBASIC'];
             $temp['name'] = $arr_subject_code['SBASIC'] . ' - ' . $item->name;
         }
         $info_calendar[$item->id] = $temp;
     }
     // echo "<pre>";
     // var_dump($info_calendar);
     // exit;
     if (count($info_calendar)) {
         $data_calendar = json_encode($info_calendar);
         $params = $data_calendar;
         $rest_add_calendarteach->add_param('data_calendar', $params);
         $result = $rest_add_calendarteach->send();
         if ($result) {
             foreach ($result->data as $key => $value) {
                 $data_update = json_decode($value);
                 // var_dump($data_update);
                 if ($data_update->calendar_code) {
                     $this->m_contact_submit->update($data_update->id, array('status_create_class' => 1, 'calendar_code' => $data_update->calendar_code));
                 }
             }
         }
     }
     echo "Thanh cong";
 }
Exemplo n.º 4
0
 public function index()
 {
     $data = $this->input->get();
     if (!$data || !isset($data['checksum_topica']) || !$data['checksum_topica']) {
         echo 'Du lieu khong hop le';
         exit;
     }
     $this->load->model('m_contact_submit');
     $this->load->model('m_contact_deposit');
     $this->load->model('m_contact');
     $deposit_checksum_code = $this->m_contact_deposit->get_one(array('m.checksum_topica' => $data['checksum_topica']));
     if (!$deposit_checksum_code) {
         $data['link_img'] = base_url() . 'themes/default/images/failed.png';
         $this->load->view('default/home/ketqua', $data);
         return FALSE;
     }
     $contact = $this->m_contact_submit->get_one(array('m.contact_id' => $deposit_checksum_code->contact_id));
     if ($contact) {
         //THUC HIEN TAO TAI KHOAN CHO HOC VIEN
         $contact_id = $data['contact_id'] = $contact->contact_id;
         $user_info = $contact;
         $data['phone'] = $user_info->phone;
         $data['actually_paid'] = $deposit_checksum_code->value < $this->tcoin_need ? $this->tcoin_need : $deposit_checksum_code->value;
         $data['full_name'] = $user_info->name;
         $data['email'] = $user_info->email;
         $arr_name = explode(" ", $data['full_name']);
         $data['first_name'] = $arr_name[count($arr_name) - 1];
         $data['last_name'] = substr($data['full_name'], 0, strlen($data['full_name']) - strlen($arr_name[count($arr_name) - 1]) - 1);
         if (!$data['last_name']) {
             $data['last_name'] = $data['first_name'];
         }
         $data['user_name'] = 'test' . strtolower($contact_id) . '@gmail.com';
         // Tao tai khoan ngan hang payment =====================================
         $this->load->model('m_sys_payment');
         $param_payment = array("ContactId" => $contact_id, "LmsId" => NULL, "UserName" => $data['full_name'], "UserPhone" => $data['phone'], "UserAtmCard" => NULL, "UserEmail" => $data['user_name'], "UserLoginName" => $data['user_name'], "UserRole" => "student", "UserArchetype" => "student");
         if (!$user_info->payment) {
             $result_payment = $this->m_sys_payment->add($param_payment);
             if (!is_object($result_payment)) {
                 $data_return["state"] = 0;
                 /* state = 0 : dữ liệu không hợp lệ */
                 $data_return["msg"] = "Có lỗi, vui lòng thử lại sau. Object";
                 echo json_encode($data_return);
                 return FALSE;
             } else {
                 if ($result_payment->status == FALSE) {
                     $data_return["state"] = 0;
                     /* state = 0 : dữ liệu không hợp lệ */
                     $data_return["msg"] = "Có lỗi, vui lòng thử lại sau. Status FALSE" . $result_payment->status_code;
                     echo json_encode($data_return);
                     return FALSE;
                 }
             }
             $this->m_contact->update(array('contact_id' => $contact_id), array('payment' => 'OK'));
         }
         // Ket thuc tao tai khoan payment ======================================
         // Deposit ngay sau tao tai khoan
         $otherInfo = array("ContactId" => $contact_id, 'lang' => isset($data['lang']) ? $data['lang'] : 'th', "Value" => $data['actually_paid'], 'TransactionBy' => 'AUTOSALE');
         $param_deposit = array("ContactId" => $contact_id, "UserName" => $data['full_name'], "UserPhone" => $data['phone'], "UserEmail" => $data['user_name'], "Value" => $data['actually_paid'], "Reason" => 'Mua goi hoc thu', "BillCode" => time(), "OtherInfo" => json_encode($otherInfo), "Time" => date('Y-m-d'), "DisableWarning" => true, "AutoTransfer" => true, 'Country' => 'VN', 'TransactionOwner' => 'AUTOSALE', 'Package' => 'TCHT');
         $result_deposit = $this->m_sys_payment->deposit($param_deposit);
         $this->m_contact->update(array('contact_id' => $contact_id), array('payment' => 'OK', 'tcoin' => $data['actually_paid'] + $contact->tcoin));
         //THUC HIEN MUA GOI HOC
         $this->load->model("m_sys_package");
         // Mua goi hoc
         $param_pricing = array('data' => array(array('user_info' => array('contact_id' => $contact_id, 'username' => $data['full_name'], 'useremail' => $data['user_name']), 'buyer_info' => array('buyer_id' => 'AUTOSALE', 'buyer_name' => 'AUTOSALE'), 'price_info' => array(array('cat_code' => 'TCHT', 'price' => $data['actually_paid'], 'actual_price' => $data['actually_paid'])), 'invoice_info' => array('reason' => 'Mua goi hoc thu'), 'course_id' => 2, 'has_active' => false)));
         $result_pricing = $this->m_sys_package->pricing($param_pricing);
         if (!is_object($result_pricing)) {
             $data_return["state"] = 0;
             $data_return["msg"] = "Chưa mua được, vui lòng thử lại sau! APIER_NOTANOJ";
             echo json_encode($data_return);
             return FALSE;
         } elseif ($result_pricing->status == false) {
             $data_return["state"] = 0;
             $data_return["msg"] = $result_pricing->msg;
             echo json_encode($data_return);
             return FALSE;
         } elseif ($result_pricing->status == true) {
             if ($result_pricing->data[0]->status == FALSE) {
                 $data_return["state"] = 0;
                 $data_return["msg"] = $result_pricing->data[0]->msg;
                 echo json_encode($data_return);
                 return FALSE;
             }
         }
         //ACTIVE GOI
         $param_active_package = array('product_id' => isset($result_pricing->data[0]->data->product_id[0]) ? $result_pricing->data[0]->data->product_id[0] : 0, 'starttime' => time(), 'timecreated' => time());
         $result_active_package = $this->m_sys_package->activePackage($param_active_package);
         // =========================== Bat dau tao user tren LMS ====================================
         $student_email = $data['email'];
         $student_phone = $data['phone'];
         $user_name_lms = trim('at' . substr(filter_var($contact_id, FILTER_SANITIZE_NUMBER_INT), -6));
         $password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6);
         $this->load->model("m_rest_client_lms");
         $rest_adduseronly = Rest_Client_Factory::create('add_user');
         $rest_adduseronly->add_params(array('users' => array(array('username' => $user_name_lms, 'firstname' => $data['first_name'], 'lastname' => $data['last_name'], 'email' => $data['user_name'], 'phone1' => $student_phone, 'password' => $password, 'lang' => 'th', 'customfields' => array(array('type' => 'contactid', 'value' => $contact_id), array('type' => 'currentlevel', 'value' => 'basic'), array('type' => 'package', 'value' => 0), array('type' => 'packageparent', 'value' => 'TAAM'), array('type' => 'studenttype', 'value' => 'AUTOSALE')))), 'enrol' => array('timestart' => time(), 'timeend' => 0, 'courseid' => 2, 'role' => 'student')));
         if (!$user_info->lms_account) {
             /**
              * id, user_name
              */
             $result_add_user = $rest_adduseronly->send();
             if ($result_add_user && isset($result_add_user->exception)) {
                 $debug = '';
                 $debug = isset($result_add_user->debuginfo) ? $result_add_user->debuginfo : '';
                 $data_return["state"] = 0;
                 $data_return["msg"] = $result_add_user->message . ' - ' . $debug;
                 $data_return["redirect"] = "";
                 echo json_encode($data_return);
                 return FALSE;
             } else {
                 if ($result_add_user == NULL) {
                     $data_return["state"] = 0;
                     $data_return["msg"] = "Chết API, chưa tạo được tài khoản";
                     $data_return["redirect"] = "";
                     echo json_encode($data_return);
                     return FALSE;
                 }
             }
             $this->m_contact->update(array('contact_id' => $contact_id), array('lms_account' => $user_name_lms, 'lms_password' => $password));
         }
         $this->m_contact_deposit->update($deposit_checksum_code->id, array('order_id' => isset($data['order_id']) ? $data['order_id'] : '', 'payment_type' => isset($data['payment_type']) ? $data['payment_type'] : '', 'transaction_id' => isset($data['transaction_id']) ? $data['transaction_id'] : $deposit_checksum_code->transaction_id, 'transaction_status' => isset($data['transaction_status']) ? $data['transaction_status'] : '', 'checksum' => isset($data['checksum']) ? $data['checksum'] : '', 'checksum_topica' => '', 'state' => 2));
         $data['user'] = $this->m_contact_submit->get_one(array('m.contact_id' => $contact_id));
         $this->m_contact_submit->update($contact->id, array('payment' => 'OK', 'auto_flag' => 3));
         $tcoin = $contact->tcoin - $this->tcoin_need;
         $this->m_contact->update(array('contact_id' => $contact_id), array('tcoin' => $tcoin));
         // gui email
         // $content_email = $this->load->view('default/email/EM03_TL', $data, true);
         // $subject_email = 'คู่มือการทดลองเรียน';
         // $this->send_email('', '', $data['user']->email, $content_email, $subject_email);
         // //gui sms
         // $content_sms = 'ลงทะเบียนเวลาการทดสอบยืนยัน'.$data['user']->time.' ngay '. date('m/d/Y',strtotime($data['user']->date)) .'. Tai khoan: '. $data['user']->lms_account .', mat khau: '. $data['user']->lms_password .'. ตรวจสอบอีเมลของคุณเพื่อดูรายละเอียด. Hotline: 02-105-4415';
         // $this->send_sms($data['user']->phone, $content_sms);
         // $this->send_sms('0982160788', $data['user']->name . ' ' . $content_sms);
     }
     // $data['msg'] = 'Giao dich thanh cong. Vui long check email de lay thong tin huong dan hoc thu';
     $data['msg'] = 'การชำระเงินสำเร็จ ! กรุณาตรวจสอบอีเมล์ของคุณสำหรับคำแนะนำในการเข้าห้องเรียน';
     $data['link_img'] = base_url() . '/themes/default/images/Thanks-V1-4.jpg';
     $this->load->view('default/home/ketqua', $data);
 }