public function get_akhir($kol, $tabel) { $this->db->order_by($kol, "DESC"); $this->db->limit(1); $query = $this->db->get($tabel); $idown = getid_own(); $kdquo = rtrim(cekoptbyid(6), $idown); if ($query->num_rows() === 0) { if ($tabel === 'quotation') { $idl = empty($kdquo) ? 4330 : $kdquo; } else { $this->db->query('ALTER TABLE ' . $tabel . ' AUTO_INCREMENT = 0;'); $idl = 1; } } else { foreach ($query->result() as $val) { if ($tabel === 'quotation') { empty($kdquo) ? $idlst = $val->{$kol} + 1 : ($idlst = $kdquo); $idl = $idlst; } else { $idl = $val->{$kol} + 1; } } } return $idl; }
public function sendEmail($email, $subject, $message, $idmng, $id, $idne) { if (!$this->session->userdata('logged_in')) { redirect('login', 'refresh'); } else { $session_data = $this->session->userdata('logged_in'); $idu = $session_data['id']; $st_user = rtrim(cekoptbyid(1)); $st_port = rtrim(cekoptbyid(5)); $st_pass = rtrim(cekoptbyid(3)); $st_host = rtrim(cekoptbyid(2)); $config['protocol'] = "smtp"; $config['smtp_host'] = empty($st_host) ? 'smtp.mandrillapp.com' : $st_host; $config['smtp_port'] = empty($st_port) ? '587' : $st_port; $config['smtp_user'] = empty($st_user) ? '*****@*****.**' : $st_user; $config['smtp_pass'] = empty($st_pass) ? 'DQilYcLI5D9Ldn0DydSudA' : $st_pass; $config['charset'] = "utf-8"; $config['newline'] = "\r\n"; $this->email->initialize($config); $this->email->set_newline("\r\n"); $this->email->set_mailtype('html'); $emailu = getemailuser($idne); $tabel = $this->mweb->getmanage_by_id($idmng); $pathe = FCPATH . 'uploads/' . $tabel . '-' . $id . '.pdf'; empty($emailu) ? $frome = '*****@*****.**' : ($frome = $emailu); $this->email->from($frome); $this->email->to($email); $this->email->subject($subject); $this->email->message($message); $this->email->attach($pathe); if (file_exists($pathe)) { if ($this->email->send()) { $this->db->where('id', $id); $query = $this->db->update($tabel, array('sent' => '1')); $loge = $this->email->print_debugger(); $this->logemail($loge); ?> <script type="text/javascript">alert('terima kasih , email berhasil terkirim :)'); </script> <?php redirect('login', 'refresh'); } else { ?> <script type="text/javascript">alert('maaf terjadi kesalahan pada system :(');</script> <?php $file = 'logerror.txt'; $pathfile = APPPATH . 'views/' . $file; $tulislog = $this->email->print_debugger(); if (file_exists($pathfile)) { $current = file_get_contents($pathfile); $current .= $tulislog; $current .= "\r\n"; // Write the contents back to the file file_put_contents($pathfile, $current); } else { $handle = fopen($pathfile, 'w') or die('Cannot open file: ' . $pathfile); fwrite($handle, $tulislog); } redirect('login', 'refresh'); } } else { $pdfe = $this->curl->simple_get(site_url('gudang/createpdf/' . $idmng . '/' . $id . '/' . $idne)); $writepdf = write_file($pathe, $pdfe); if ($writepdf) { if ($this->email->send()) { $this->db->where('id', $id); $query = $this->db->update($tabel, array('sent' => '1')); $loge = $this->email->print_debugger(); $this->logemail($loge); $this->db->where('id', $id); switch ($idmng) { case '6': $this->db->update('invoice', array('acc' => '1')); break; case '7': $this->db->update('quotation', array('acc' => '1')); break; } ?> <script type="text/javascript">alert('terima kasih , email berhasil terkirim :)');</script> <?php redirect('login', 'refresh'); } else { $loge = $this->email->print_debugger(); $this->logemail($loge); } } else { ?> <script type="text/javascript"> alert('maaf terjadi kesalahan pada system'); </script> <?php } } } }
echo cekoptbyid($valdata[$fkolm]); ?> " /> <?php } ?> <span class="input-group-btn"> <button class="btn btn-success" type="submit">simpan</button> </span> </div> </form> <?php } else { ?> <strong><?php echo cekoptbyid($valdata[$fkolm]); ?> </strong> <?php } } else { echo $valdata[$valkol]; } } break; case 'catatan': if (strlen($valdata[$valkol]) > 15) { echo substr($valdata[$valkol], 0, 16) . '. . .'; } else { echo $valdata[$valkol]; }