📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
otelscripti.demodesign.com.tr
/
admin
/
controllers
📝
RoomAdminController.php
← Geri Dön
<?php use Sirius\Admin\Manager; class RoomAdminController extends Manager { public $moduleTitle = 'Odalar'; public $module = 'room'; public $table = 'rooms'; public $model = 'room'; public $type = 'public'; public $menuPattern = [ 'title' => 'title', 'hint' => 'title', 'link' => ['slug', 'id'], 'moduleLink' => true, 'language' => true ]; public $search = ['title']; public $actions = [ 'records' => 'list', 'order' => 'list', 'insert' => 'insert', 'update' => 'update', 'delete' => 'delete', 'images' => 'image-list', 'imageOrder' => 'image-list', 'imageInsert' => 'image-insert', 'imageUpdate' => 'image-update', 'imageDelete' => 'image-delete', ]; protected function insertRequest() { $extras = $this->appmodel->allExtra(); $this->viewData['extras'] = $extras; $this->viewData['fiyatlar'] = [ 1 => 'Yetişkin', 2 => 'Çocuk', ]; //$hotels= $this->appmodel->hotels(); //$this->load->vars('hotels',$hotels); $this->load->vars('public', ['js' => [ '../public/admin/plugin/ckeditor/ckeditor.js', '../public/admin/plugin/ckfinder/ckfinder.js' ]]); } protected function insertValidateRules() { $this->form_validation->set_rules('title', 'Lütfen başlık yazınız.', 'required'); $this->form_validation->set_rules('summary', 'Lütfen özet yazınız.', 'required'); $this->form_validation->set_rules('detail', 'Lütfen detay yazınız.', 'required'); if ($this->input->post('autoSlug') !== 'true') { $this->form_validation->set_rules('slug', 'Lütfen slug yazınız.', 'required'); } } protected function insertAfterValidate() { $this->utils ->uploadInput('imageFile') ->minSizes(480, 360) ->addProcessSize('normal', 480, 360, 'room', 'thumbnail'); if ($this->input->post('imageUrl')) { $this->modelData['image'] = $this->utils->imageDownload(true, $this->input->post('imageUrl')); } else { $this->modelData['image'] = $this->utils->imageUpload(true); } } protected function updateRequest() { if ($this->uri->segment(1) == 'room') { $this->viewData['extras'] = $this->appmodel->allExtra(); $extraValidation = $this->appmodel->extraValidation($this->uri->segment(3)); $extraId = []; foreach ($extraValidation as $val) { $extraId[] .= $val->extraId; } $this->viewData['extraValidation'] = $extraId; $this->viewData['fiyatlar'] = [ 1 => 'Yetişkin', 2 => 'Çocuk', ]; $this->load->model('Room'); $this->viewData['roomMoneys'] = $this->room->roomManyAll($this->uri->segment(3)); } //$hotels= $this->appmodel->hotels(); //$this->load->vars('hotels',$hotels); $this->load->vars('public', ['js' => [ '../public/admin/plugin/ckeditor/ckeditor.js', '../public/admin/plugin/ckfinder/ckfinder.js' ]]); } protected function updateValidateRules() { $this->form_validation->set_rules('title', 'Lütfen başlık yazınız.', 'required'); $this->form_validation->set_rules('summary', 'Lütfen özet yazınız.', 'required'); $this->form_validation->set_rules('detail', 'Lütfen detay yazınız.', 'required'); if ($this->input->post('autoSlug') !== 'true') { $this->form_validation->set_rules('slug', 'Lütfen slug yazınız.', 'required'); } } protected function updateAfterValidate($record) { $gallery = $this->appmodel->id($this->uri->segment(3)); if(!empty( $gallery->photoName)){ $_REQUEST['specific_name']= $gallery->photoName; } $this->utils ->uploadInput('imageFile') ->minSizes(480, 360) ->addProcessSize('normal', 480, 360, 'room', 'thumbnail'); if ($this->input->post('imageUrl')) { $this->modelData['image'] = $this->utils->imageDownload(false, $this->input->post('imageUrl'), $record->image); } else { $this->modelData['image'] = $this->utils->imageUpload(false, $record->image); } unset($_REQUEST['specific_name']); } public function images() { if (! $parent = $this->appmodel->id($this->uri->segment(3))) { show_404(); } $records = []; $pagination = null; $recordCount = $this->appmodel->imageCount($parent); if ($recordCount > 0) { $config = [ 'base_url' => clink([$this->module, 'images', $parent->id]), 'total_rows' => $recordCount, 'per_page' => 20 ]; $this->load->library('pagination'); $this->pagination->initialize($config); $records = $this->appmodel->imageAll($parent, $this->pagination->per_page, $this->pagination->offset); $pagination = $this->pagination->create_links(); } $this->breadcrumb($parent->title, clink([$this->module, 'update', $parent->id])); $this->breadcrumb('Resimler', clink([$this->module, 'images', $parent->id])); $this->breadcrumb('Kayıtlar'); $this->viewData['parent'] = $parent; $this->viewData['records'] = $records; $this->viewData['pagination'] = $pagination; $this->load->vars('public', ['js' => [ '../public/admin/plugin/plupload/plupload.js', '../public/admin/plugin/plupload/plupload.flash.js', '../public/admin/plugin/plupload/plupload.html4.js', '../public/admin/plugin/plupload/plupload.html5.js', ]]); $this->render('images/records'); } public function imageInsert() { if (! $parent = $this->appmodel->id($this->uri->segment(3))) { echo json_encode([ 'jsonrpc' => '2.0', 'error' => ['code' => '500', 'message' => 'Kayıt bulunamadı.'], 'id' => 'id' ]); } $room = $this->appmodel->id($this->uri->segment(3)); if(!empty( $room->photoName)){ $_REQUEST['specific_name']= $room->photoName; } $this->utils ->setPlupload() ->uploadInput('file') ->minSizes(500, 500) ->addProcessSize('thumb', 200, 200, 'room/thumb', 'fit') ->addProcessSize('normal', 1024, null, 'room/normal', 'fit-width'); $this->modelData['image'] = $this->utils->imageUpload(true); $success = $this->appmodel->imageInsert($parent, $this->modelData); unset($_REQUEST['specific_name']) ; if ($success) { echo json_encode([ 'jsonrpc' => '2.0', 'error' => [], 'id' => 'id' ]); return; } } public function imageUpdate() { if (! $record = $this->appmodel->image($this->uri->segment(3))) { show_404(); } $parent = $this->appmodel->id($record->estateId); if ($this->input->post()) { if ($this->form_validation->run() === false) { $this->utils->setAlert('danger', $this->form_validation->error_string('<div>• ', '</div>')); } $this->utils ->uploadInput('imageFile') ->minSizes(500, 500) ->addProcessSize('thumb', 200, 200, 'room/thumb', 'fit') ->addProcessSize('normal', 1024, null, 'room/normal', 'fit-width'); if ($this->input->post('imageUrl')) { $this->modelData['image'] = $this->utils->imageDownload(false, $this->input->post('imageUrl'), $record->image); } else { $this->modelData['image'] = $this->utils->imageUpload(false, $record->image); } if (! $this->utils->isAlert()) { $success = $this->appmodel->imageUpdate($record, $this->modelData); if ($success) { $this->utils->setAlert('success', 'Kayıt düzenlendi.'); redirect(clink([$this->module, 'imageUpdate', $record->id])); } $this->utils->setAlert('warning', 'Kayıt düzenlenmedi.'); } } $this->breadcrumb($parent->title, clink([$this->module, 'update', $parent->id])); $this->breadcrumb('Resimler', clink([$this->module, 'images', $parent->id])); $this->breadcrumb('Kayıt Düzenle'); $this->viewData['parent'] = $parent; $this->viewData['record'] = $record; $this->render('images/update'); } public function imageDelete() { // Ajax sorgusu ise toplu silme uygulanır if ($this->input->is_ajax_request()) { $ids = $this->input->post('ids'); if (count($ids) == 0) { $this->utils->setAlert('danger', 'Lütfen kayıt seçiniz.'); echo $this->input->server('HTTP_REFERER'); } $success = $this->appmodel->imageDelete($ids); if ($success) { $this->utils->setAlert('success', "Kayıtlar başarıyla silindi."); echo $this->input->server('HTTP_REFERER'); } return true; } // Normal sorgu ise tekli silme uygulanır if (! $record = $this->appmodel->image($this->uri->segment(3))) { show_404(); } $success = $this->appmodel->imageDelete($record); if ($success) { $this->utils->setAlert('success', "Kayıt kaldırıldı. (#{$record->id})"); redirect($this->input->server('HTTP_REFERER')); } $this->utils->setAlert('danger', 'Kayıt kaldırılamadı.'); redirect($this->input->server('HTTP_REFERER')); } /** * Sıralama işlemi yapar */ public function imageOrder() { $ids = explode(',', $this->input->post('ids')); if (count($ids) == 0){ $this->utils->setAlert('danger', 'Lütfen kayıt seçiniz.'); } $success = $this->appmodel->imageOrder($ids); if ($success){ $this->utils->setAlert('success', "Kayıtlar başarıyla sıralandı."); } } }
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula