public function view() { if ($_POST) { if (empty($_POST['username'])) { parent::alert('error', 'Error', 'Kolom username kosong !'); } else { if (empty($_POST['password'])) { parent::alert('error', 'Error', 'Kolom password kosong !'); } else { $username = esc_string($_POST['username']); $password = esc_string(md5($_POST['password'])); $login = $this->login->user_login('admin', $username, $password); switch ($login) { case 0: parent::alert('error', 'Error', 'User tidak ditemukan !'); break; case 1: redirect('index.php?page=home'); break; case 2: parent::alert('error', 'Error', 'Terjadi kesalahan ! <br />' . mysql_errno()); break; default: break; } } } } $this->view->display('login.tpl'); }
private function saving($mode, $id = '') { if (!empty($_POST['username']) && !empty($_POST['password'])) { if ($_POST['re_password'] == $_POST['password']) { if ($mode == 'new') { $query = $this->user->save_user(); } else { if ($mode == 'update') { $query = $this->user->update_user($id); } } if ($query) { parent::alert('success', 'Berhasil !', 'Data user berhasil disimpan ! <a href=' . $this->base_link . '>Klik disini</a> untuk kembali'); } else { parent::alert('error', 'Gagal !', 'Data user gagal disimpan !'); } } } }
private function site_profile() { if ($_POST) { if (!empty($_POST['site_name'])) { $site = $this->profile->update_profile($_POST['id']); if ($site) { parent::alert('success', 'Berhasil !', 'Data konfigurasi website berhasil disimpan !'); } else { parent::alert('error', 'Gagal !', 'Data konfigurasi website gagal disimpan !'); } } } $profile = $this->profile->base_profile(); if ($profile['site_status'] == 'online') { $site_status = $this->radio_config('site_status', 'checked'); } else { $site_status = $this->radio_config('site_status', '', 'checked'); } $site_data = $this->site_data($profile['id'], $profile['date_updated'], $profile['site_name'], $profile['site_author'], $profile['site_slogan'], $profile['site_footer'], $site_status, $profile['offline_message'], $profile['site_meta_desc'], $profile['site_meta_key']); $this->form_data('Konfigurasi website', $site_data); }
private function view_customer() { $id = $_GET['id']; if ($_POST) { $update = $this->customer->update_blocked_status_customer($id); if ($update) { redirect($this->base_link); } else { parent::alert('error', 'Gagal !', 'Gagal merubah status pelanggan !'); } } $customer = $this->customer->get_customer('', $id); $detail = $this->customer->get_customer('detail', $id); if ($customer['blocked'] == 'N') { $status = $this->radio_config('blocked', 'checked', ''); } else { $status = $this->radio_config('blocked', '', 'checked'); } $customer_data = array(array('label' => '<img src="' . $this->img_dir . 'no_image.jpg" />', 'input' => ''), array('label' => 'Tgl registrasi', 'input' => html_input('text', array('value="' . $customer['reg_date'] . '"', 'class="span3"', 'disabled'))), array('label' => 'Nama lengkap', 'input' => html_input('text', array('value="' . $detail['fullname'] . '"', 'class="span3"', 'disabled'))), array('label' => 'Status', 'input' => $status), array('label' => 'Jenis kelamin', 'input' => html_input('text', array('value="' . $detail['sex'] . '"', 'class="span3"', 'disabled'))), array('label' => 'Alamat', 'input' => html_textarea(array('class="span6"', 'disabled'), $detail['address'])), array('label' => 'Provinsi', 'input' => html_input('text', array('value="' . $detail['state'] . '"', 'class="span3"', 'disabled'))), array('label' => 'Kota', 'input' => html_input('text', array('value="' . $detail['city'] . '"', 'class="span3"', 'disabled'))), array('label' => 'Kode pos', 'input' => html_input('text', array('value="' . $detail['postal_code'] . '"', 'class="span3"', 'disabled'))), array('label' => 'No.Telp', 'input' => html_input('text', array('value="' . $detail['phone_number'] . '"', 'class="span3"', 'disabled'))), array('label' => 'Email', 'input' => html_input('text', array('value="' . $detail['email'] . '"', 'class="span3"', 'disabled')))); $button = array(html_input('submit', array('value="Simpan"', 'class="btn btn-success"')), html_input('button', array('value="Kirim Pesan"', 'onClick="window.location.go(-1)"', 'class="btn btn-success"'))); parent::form_config('', '', $customer_data, 'Data pelanggan', $button); }
private function site_config() { if ($_POST) { if (!empty($_POST['site_name'])) { $site = $this->site_config->update($_POST['id']); if ($site) { parent::alert('success', 'Berhasil !', 'Data konfigurasi website berhasil disimpan !'); } else { parent::alert('error', 'Gagal !', 'Data konfigurasi website gagal disimpan !'); } } } $row = $this->site_config->get_row(); if ($row['site_status'] == 'online') { $site_status = $this->radio_config('site_status', 'checked'); } else { $site_status = $this->radio_config('site_status', '', 'checked'); } $values_site_conf = array($row['date_updated'], $row['id'], $row['site_name'], $row['site_author'], $row['site_slogan'], $row['site_footer'], $site_status, $row['offline_message'], $row['site_meta_desc'], $row['site_meta_key']); $values_other_conf = array(); $site_data = $this->site_data($values_site_conf); $other_conf = $this->other_conf($values_other_conf); $this->form('Konfigurasi website', array($site_data, $other_conf)); }
private function saving($mode = '', $id = '', $image_name = '') { $img_src = $_FILES['image']['tmp_name']; $img_name = $_FILES['image']['name']; $img_type = $_FILES['image']['type']; $img_size = $_FILES['image']['size']; $rand = rand(00, 999999); $uniq_file_name = $rand . $img_name; if (empty($img_src)) { $image = $image_name; } else { $image = $uniq_file_name; } if ($mode == 'new') { $query = $this->product->save_product($image); } else { if ($mode == 'update') { $query = $this->product->update_product($id, $image); } } if ($query) { if (!empty($img_src)) { img_upload($img_src, $this->img_dir, $image, 'thumb'); } parent::alert('success', 'Berhasil !', 'Data produk berhasil disimpan ! <a href=' . $this->base_link . '>Klik disini</a> untuk kembali'); } else { parent::alert('error', 'Gagal !', 'Data produk gagal disimpan !'); } }
private function saving($mode = '', $id = '', $image_name = '') { $img_src = $_FILES['image']['tmp_name']; $img_name = $_FILES['image']['name']; $img_type = $_FILES['image']['type']; $img_size = $_FILES['image']['size']; $rand = rand(00, 999999); $uniq_file_name = $rand . $img_name; if (empty($img_src)) { $image = $image_name; } else { $image = $uniq_file_name; } if ($mode == 'new') { $query = $this->hs->save_home_slider($image); } else { if ($mode == 'update') { $query = $this->hs->update_home_slider($id, $image); } } if ($query) { if (!empty($img_src)) { img_upload($img_src, $this->img_dir, $image, 'slider', 962, 356); unlink($this->img_dir . $image); } parent::alert('success', 'Berhasil !', 'Data home slider berhasil disimpan ! Silahkan tambah data lagi atau <a href=' . $this->base_link . '>Klik disini</a> untuk kembali'); } else { parent::alert('error', 'Gagal !', 'Data home slider gagal disimpan !'); } }
private function edit_brand() { $brand = $this->brand->get_brand($_GET['id']); if ($_POST) { $img_src = $_FILES['image']['tmp_name']; $img_name = $_FILES['image']['name']; $img_type = $_FILES['image']['type']; $img_size = $_FILES['image']['size']; $dir = $this->img_dir; $rand = rand(00, 999999); $uniq_file_name = $rand . $img_name; if (empty($img_src)) { $image = $brand['image']; } else { $image = $uniq_file_name; } $query = $this->brand->update_brand($_GET['id'], $image); if ($query) { if (!empty($img_src)) { img_upload($img_src, $dir, $image, 'thumb'); } parent::alert('success', 'Berhasil !', 'Data brand berhasil diubah !'); } else { parent::alert('error', 'Gagal !', 'Data brand gagal diubah !'); } } if ($brand['publish'] == 'Y') { $publish = $this->radio_config('publish', 'checked', ''); } else { $publish = $this->radio_config('publish', '', 'checked'); } $brand_data = $this->brand_data($_GET['id'], $brand['name'], $brand['image'], $brand['description']); $brand_config = $this->brand_config($publish, $brand['meta_desc'], $brand['meta_key']); $this->form_data('Ubah data brand', $brand_data, $brand_config); }
private function edit_pcategory() { $pcategory = $this->pcategory->get_pcategory($_GET['id']); if ($_POST) { $img_src = $_FILES['image']['tmp_name']; $img_name = $_FILES['image']['name']; $img_type = $_FILES['image']['type']; $img_size = $_FILES['image']['size']; $dir = $this->img_dir; $rand = rand(00, 999999); $uniq_file_name = $rand . $img_name; if (empty($img_src)) { $image = $pcategory['image']; } else { $image = $uniq_file_name; } $query = $this->pcategory->update_pcategory($_GET['id'], $image); if ($query) { if (!empty($img_src)) { img_upload($img_src, $dir, $image, 'thumb'); } parent::alert('success', 'Berhasil !', 'Data kategori produk berhasil disimpan ! Silahkan tambah data lagi atau <a href=' . $this->base_link . '>Klik disini</a> untuk kembali'); } else { parent::alert('error', 'Gagal !', 'Data kategori produk gagal disimpan !'); } } if ($pcategory['publish'] == 'Y') { $publish = $this->radio_config('publish', 'checked', ''); } else { $publish = $this->radio_config('publish', '', 'checked'); } $pcategory_data = $this->pcategory_data($_GET['id'], $_GET['id'], $pcategory['name'], $pcategory['image'], $pcategory['description']); $pcategory_config = $this->pcategory_config($publish, $pcategory['meta_desc'], $pcategory['meta_key']); $this->form_data('Ubah data kategori produk', $pcategory_data, $pcategory_config); }