function save($data) { $app_id = $data['app_id']; if ($q = $this->db->query("select a.cust_id,c.cust_name,c.phone \n\t\t\tfrom ls_app_master a left join ls_cust_master c\n\t\t\ton a.cust_id=c.cust_id where a.app_id='" . $app_id . "'")) { if ($row = $q->row()) { $data['cust_id'] = $row->cust_id; $data['cust_name'] = $row->cust_name; $data['phone'] = $row->phone; } } $score = 0; foreach ($data as $key => $value) { if ($value == "1") { $score++; } } $score = round($score / 14 * 100); $ok = $this->db->insert($this->table_name, $data); if ($ok) { if ($score > 75) { $this->db->where("app_id", $app_id)->update("ls_app_master", array("scored" => 1, "score_value" => $score, "status" => "Wait Review")); } else { //masuk inbox sa nomor SPK ditolak $message = "Nomor SPK {$app_id} tidak memenuhi syarat score value = {$score}"; $to = $this->db->select("create_by")->where("app_id", $app_id)->get("ls_app_master")->row()->create_by; inbox_send(user_id(), $to, "Not Recomended", $message); $this->db->where("app_id", $app_id)->update("ls_app_master", array("scored" => 1, "score_value" => $score, "status" => "Not Recomended")); } } return $ok; }
function not_recomend() { $app = $this->input->post('pilih'); for ($i = 0; $i < count($app); $i++) { $app_id = $app[$i]; $ok = $this->db->where("app_id", $app_id)->update("ls_app_survey", array("recomended" => 2)); $ok = $this->db->where("app_id", $app_id)->update("ls_app_master", array("status" => "Not Recomended")); $from = user_id(); $to_user = $this->db->select("create_by")->where("app_id", $app_id)->get("ls_app_master")->row()->create_by; inbox_send($from, $to_user, $app_id . " - Not Recomended", "Nomor Aplikasi: {$app_id} tidak setujui {$from}"); } if ($ok) { echo json_encode(array("success" => true)); } else { echo json_encode(array("msg" => "Error " . mysql_error())); } }
function proses_tagih() { $data["visit_date"] = date("Y-m-d H:i:s", strtotime($this->input->post("visit_date"))); $data["visit_notes"] = $this->input->post("visit_notes"); $data["collected"] = $this->input->post("tertagih"); $data['amount_col'] = $this->input->post("tertagih_jumlah"); $promise_date = date("Y-m-d H:i:s", strtotime($this->input->post("janji_tanggal"))); $data['promise_date'] = $promise_date; $faktur = $this->input->post("invoice_no"); $data['visit_ke'] = $this->input->post("visit_ke"); $data['visited'] = 1; $ok = $this->db->where("invoice_no", $faktur)->update("ls_loan_col_sched", $data); //update ke visit_count billing $cnt = $this->db->query("select count(1) as cnt from ls_loan_col_sched \n\t\t\twhere invoice_no='" . $faktur . "'")->row()->cnt; $this->db->where("invoice_number", $faktur)->update("ls_invoice_header", array("visit_count" => $cnt)); if ($ok) { $message = "Belum tertagih invoice {$faktur} janji bayar tanggal {$promise_date}"; $from = user_id(); $to_user = "******"; inbox_send($from, $to_user, $faktur . " - belum tertagih", $message); echo json_encode(array("success" => true)); } else { echo json_encode(array("msg" => "Tidak bisa simpan !")); } }
function save_schedule($data) { $tanggal = $data['loan_date']; $loan_id = $data['loan_id']; $ok = true; for ($i = 0; $i < count($loan_id); $i++) { $ok = $this->db->where("loan_id", $loan_id[$i])->update("ls_loan_master", array("loan_date_aggr" => date("Y-m-d 00:00:00", strtotime($tanggal[$i])))); //ngasih inbox ke admls sudah dibuat jadwal antara sa dan debitur $from = user_id(); $to_user = '******'; $loan = null; $cust_name = "Unknown"; if ($q = $this->db->select("cust_id")->where("loan_id", $loan_id[$i])->get("ls_loan_master")) { if ($q->row()) { $loan = $q->row(); } } if ($loan) { $cust = $this->db->select("cust_name")->where("cust_id", $loan->cust_id)->get("ls_cust_master")->row(); $cust_name = $cust->cust_name; } $subject = $loan_id[$i] . " - Sudah dibuatkan schedule \n\t\t\t\ttanggal " . $tanggal[$i] . ", Debitur: {$cust_name}"; $message = $subject; inbox_send($from, $to_user, $subject, $message); } return $ok; }
function not_recomend_save() { $data_spk = $this->input->post("pilih"); for ($i = 0; $i < count($data_spk); $i++) { $from = user_id(); $app_id = $data_spk[$i]; $app = $this->db->select("create_by,cust_id")->where("app_id", $app_id)->get("ls_app_master")->row(); if ($app) { $to_user = $app->create_by; $cust_name = $app->cust_id; if ($cust_name != "") { $cust_name = $this->db->select("cust_name")->where("cust_id", $cust_name)->get("ls_cust_master")->row()->cust_name; } } inbox_send($from, $to_user, $app_id . " - Nama: {$cust_name} - Not Recommended", "Nomor Aplikasi: {$app_id} tidak setujui {$from} - Nama: {$cust_name}."); $ok = $this->db->where("app_id", $app_id)->update("ls_app_master", array("confirmed" => 2, "status" => "Not Recomend")); } }
function not_recomended() { $app_id = $this->input->get("app_id"); $reason = $this->input->get("reason"); $data['status'] = 'Not Recomended'; if ($this->db->where("app_id", $app_id)->update("ls_app_master", $data)) { $from = user_id(); $to_user = $this->db->select("create_by")->where("app_id", $app_id)->get("ls_app_master")->row()->create_by; inbox_send($from, $to_user, $app_id . " - Not Recomended", "Nomor Aplikasi: {$app_id} tidak setujui {$from} , dengan alasan {$reason}"); echo "Sukses, status aplikasi sudah diberitahukan ke sales agentnya. Silahkan close dan refresh."; } else { echo "Ada kesalahan !"; } }