Beispiel #1
0
 public function run($id = false, $model = false, $forceDelete = false)
 {
     $modelName = $this->model && is_string($this->model) ? $this->model : (request()->getParam('model') ? request()->getParam('model') : $this->controller->model);
     if ($id) {
         //delete one model
         $result = $this->controller->loadModel($modelName, $id)->delete();
         if (!request()->isAjaxRequest && $result) {
             $this->controller->redirect(user()->gridIndex);
         }
         Common::jsonSuccess(true);
     } else {
         $items = Common::getChecked('items');
         if ($items) {
             if (!$forceDelete) {
                 foreach ($items as $id) {
                     $this->controller->loadModel($modelName, $id)->delete();
                 }
             } else {
                 $criteria = new SDbCriteria();
                 $criteria->compare('id', $items);
                 CActiveRecord::model($modelName)->deleteAll($criteria);
             }
             Common::jsonSuccess(true);
         }
     }
     Common::jsonError("Ошибка");
 }
function deleteHotelFetursList()
{
    $hotelfeatureslist = new HotelFetursList();
    $hotelfeatureslist->setHotelFeatureListId($_REQUEST['id']);
    if ($hotelfeatureslist->deleteHotelFeatureList()) {
        Common::jsonSuccess("Hotel Features List Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
function deleteMemberBankDetail()
{
    $member_bank_details = new MemberBankDetails();
    $member_bank_details->setBankId($_REQUEST['id']);
    if ($member_bank_details->deleteMemberBankDetails()) {
        Common::jsonSuccess("Member Bank Details Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
function deleteAdministrator()
{
    $admin = new Administrators();
    $admin->setId($_REQUEST['id']);
    if ($admin->deleteAdministrator()) {
        Common::jsonSuccess("Adminstrators Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
function subscribe()
{
    $subscribe = new Subscribe();
    $subscribe->setValues($_REQUEST);
    if ($subscribe->newSubscribe()) {
        Common::jsonSuccess("Subscribe Successfully!");
    } else {
        Common::jsonError("Error");
    }
}
function deleteRoomFeatures()
{
    $room_features = new RoomFeatures();
    $room_features->setRoomFeatureId($_REQUEST['id']);
    if ($room_features->deleteRoomFeatures()) {
        Common::jsonSuccess("Room Features Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #7
0
function deleteCategory()
{
    $category = new Category();
    $category->setCategoryId($_REQUEST['id']);
    if ($category->deleteCategory()) {
        Common::jsonSuccess("Category Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
function deleteHotelFetursType()
{
    $hotelfeat_type = new HotelFetursType();
    $hotelfeat_type->setHotelFeatureTypeId($_REQUEST['id']);
    if ($hotelfeat_type->deleteHotelFeatureType()) {
        Common::jsonSuccess("Feturs Type Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #9
0
function deleteCurrency()
{
    $currency = new Currency();
    $currency->setCurrId($_REQUEST['id']);
    if ($currency->deleteCurrency()) {
        Common::jsonSuccess("Currency Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
function deleteAccommodation()
{
    $accommodation = new Accommodation();
    $accommodation->setAccommodationId($_REQUEST['id']);
    if ($accommodation->deleteAccommodation()) {
        Common::jsonSuccess("Accommodation Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #11
0
function updateSettings()
{
    $sysSettings = new systemSetting();
    $get_edited = array();
    foreach ($_REQUEST as $k => $v) {
        $get_edited[$k] = $v;
    }
    $sysSettings->setValues($get_edited);
    if ($sysSettings->editSetting()) {
        Common::jsonSuccess("Settings Update Successfully!");
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #12
0
function adminLoginNow()
{
    $username = $_REQUEST['login_user'];
    $password = $_REQUEST['login_password'];
    $admin = new administrator();
    $admin->setUsername($username);
    $data = $admin->getAdminFromUsername();
    if (count($data) > 0) {
        $admin->extractor($data);
        if ($admin->password() == md5($password)) {
            $session = new Sessions();
            $session->setAdminLoginSessions($admin->id(), $admin->name(), $admin->email());
            Common::jsonSuccess("Success");
        } else {
            Common::jsonError("Login Error");
        }
    } else {
        Common::jsonError("Login Error");
    }
}
Beispiel #13
0
function memberLogin()
{
    $member = new Members();
    $member->setMemberUsername($_REQUEST['member_username_login']);
    $data = $member->getMemberByUsername();
    if (count($data) > 0) {
        $member->extractor($data);
        if (strcmp($member->memberPassword(), md5($_REQUEST['member_password_login'])) == 0) {
            $session = new Sessions();
            $session->setMemberLoginSessions($member->memberId(), $member->memberTitle(), $member->memberFirstName(), $member->memberLastName());
            Common::jsonSuccess("Success");
        } else {
            Common::jsonError("Login Error");
        }
    } else {
        Common::jsonError("Login Error");
    }
}
function loginClient()
{
    $username = $_REQUEST['client_username_log'];
    $password = $_REQUEST['client_password_log'];
    $client = new Clients();
    $session = new Sessions();
    $client->setClientUsername($username);
    $data = $client->getClientFromUsername();
    if (count($data) > 0) {
        $client->extractor($data);
        if (strcmp($client->clientPassword(), md5($password)) == 0) {
            $session->setClientLoginSessions($client->clientId(), $client->clientTitle(), $client->clientFirstName(), $client->clientLastName());
            Common::jsonSuccess("Success");
        } else {
            Common::jsonError("Login Error");
        }
    } else {
        Common::jsonError("Login Error");
    }
}
Beispiel #15
0
 public function actionIsGuest()
 {
     if (user()->isGuest) {
         Common::jsonSuccess(true);
     } else {
         Common::jsonSuccess(true, ['success' => false]);
     }
 }
Beispiel #16
0
 /**
  * Возвращает комментарии к заказу
  */
 public function actionGetCommentsOnHover()
 {
     $ownerModelName = request()->getParam('ownerModelName');
     $idOwner = request()->getParam('idOwner');
     $commentsRelation = request()->getParam('commentsRelation');
     $title = request()->getParam('title') ? request()->getParam('title') . $idOwner : '';
     if (!$idOwner) {
         Common::jsonSuccess(true, ['success' => false, 'error' => 'Произошла ошибка при запросе']);
     }
     $resultComments = '';
     $ownerModel = $this->owner->loadModel($ownerModelName, $idOwner);
     $comments = $ownerModel->{$commentsRelation};
     $resultComments .= CHtml::openTag('div', ['class' => 'comment-block-item']);
     $resultComments .= CHtml::tag('h4', ['class' => 'fsize16 m0'], $title);
     if (!$comments) {
         $resultComments .= CHtml::tag('div', ['class' => 'comment comment-no-result tcenter p5 fsize13 clearfix'], 'Нет результатов.');
     } else {
         foreach ($comments as $comment) {
             $ownerComment = $comment->render();
             $resultComments .= CHtml::openTag('div', ['class' => 'comment p5 fsize13 clearfix']) . CHtml::tag('span', ['class' => 'c-black fl w360'], nl2br($comment->comment)) . CHtml::tag('p', ['class' => 'c-dark-gray m0 fr w140'], date('d/m H:i', strtotime($comment->date)) . ', ' . ($comment->user ? $comment->user->username : '')) . CHtml::closeTag('div');
         }
     }
     $resultComments .= CHtml::closeTag('div');
     if (!$resultComments) {
         Common::jsonSuccess(true, ['success' => false, 'error' => 'Ошибка при обработке комментариев']);
     }
     Common::jsonSuccess(true, compact('resultComments'));
 }
Beispiel #17
0
function deleteHotel()
{
    $admin = new Hotels();
    $admin->setHotelId($_REQUEST['id']);
    if ($admin->deleteHotel()) {
        Common::jsonSuccess("Hotel Deleted Succesfully");
    } else {
        Common::jsonError("Error");
    }
}
function deleteReservation()
{
    $reservation = new Reservations();
    $reservation->setReservationId($_REQUEST['id']);
    if ($reservation->deleteReservations()) {
        Common::jsonSuccess("Reservation Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #19
0
 public function run($id)
 {
     $modelName = $this->model && is_string($this->model) ? $this->model : $this->controller->model;
     $model = $this->controller->loadModel($modelName, $id, $this->with, $this->multilang);
     if ($this->slugger) {
         $model->attachBehavior('slugger', ['class' => 'core.behaviors.SlugBehavior', 'sourceAttribute' => isset($this->slugger['sourceAttribute']) ? $this->slugger['sourceAttribute'] : 'title', 'slugAttribute' => isset($this->slugger['slugAttribute']) ? $this->slugger['slugAttribute'] : 'slug']);
     }
     // Uncomment the following line if AJAX validation is needed
     $this->controller->performAjaxValidation($model);
     $this->controller->pageTitle = $this->title;
     // $this->controller->pageDesc  = t('admin', 'Заполните поля для редактирования записи');
     $this->controller->breadcrumbs = $this->breadcrumbs ? $this->breadcrumbs : [$this->controller->title => ['index'], $this->controller->pageTitle];
     if (isset($_POST[$modelName])) {
         $model->attributes = $_POST[$modelName];
         if ($this->beforeSave) {
             call_user_func_array($this->beforeSave, [$model]);
         }
         if ($model->validate()) {
             if (!empty($model->withRelatedObjects)) {
                 $result = $model->withRelated->save(false, $model->withRelatedObjects);
             } else {
                 $result = $model->save(false);
             }
             if ($result) {
                 if ($this->afterSave) {
                     call_user_func_array($this->afterSave, [$model]);
                 }
                 if (request()->isAjaxRequest) {
                     Common::jsonSuccess(true);
                 }
                 //объязательно
                 if (request()->getParam('close') == 'true') {
                     $this->controller->redirect(user()->gridIndex);
                 } else {
                     $this->controller->refresh();
                 }
             }
         }
     }
     if ($this->viewAsArray) {
         // загружаем форму через конструктор форм
         $config = (require $this->controller->module->basePath . '/views/' . $this->controller->id . '/form.php');
         if (!isset($config['buttons'])) {
             $config['buttons'] = ['group' => $model->isNewRecord ? 'create' : 'update'];
         }
         $form = new SForm($config, $model);
         $params = compact('form', 'model');
         $view = 'update';
     } else {
         $params = compact('model');
         $view = $this->view ? $this->view : 'form';
     }
     if ($this->beforeRender) {
         call_user_func_array($this->beforeRender, [$model, &$params]);
     }
     if (!request()->isAjaxRequest) {
         if ($this->languageSelector) {
             $this->controller->languageSelector = $this->languageSelector;
         }
         $this->controller->render($view, $params);
     }
 }
Beispiel #20
0
function removeOfferImage()
{
    $offerId = $_REQUEST['offerId'];
    $file = $_REQUEST['image'];
    $file_path = DOC_ROOT . 'uploads/special_offers/' . $file;
    $offers = new Offers();
    if (file_exists($file_path)) {
        if (unlink($file_path)) {
            $offers->setId($_REQUEST['offerId']);
            $offers->deleteImage();
            Common::jsonSuccess("Offer image deleted successfully");
        } else {
            Common::jsonError("Failed to delete");
        }
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #21
0
function deleteMainCityImage()
{
    $file = $_REQUEST['image'];
    $file_path = DOC_ROOT . 'uploads/main-city/' . $file;
    if (file_exists($file_path)) {
        if (unlink($file_path)) {
            $maincity = new MainCity();
            $maincity->setMainCityId($_REQUEST['id']);
            $data = $maincity->getMainCityFromId();
            $maincity->extractor($data);
            $imagelist = $maincity->mainCityImage();
            $imgs = explode(',', $imagelist);
            $key = array_search($file, $imgs);
            if (false !== $key) {
                unset($imgs[$key]);
            }
            for ($x = 0; $x <= count($imgs); $x++) {
                if (!empty($imgs[$x])) {
                    $update_img .= $imgs[$x] . ',';
                }
            }
            $maincity->setMainCityImage($update_img);
            $maincity->updateMainCityImages();
            Common::jsonSuccess("City Image Deleted Successfully");
        } else {
            Common::jsonError("Fail To Delete");
        }
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #22
0
function deactivateHotelRequestCancel()
{
    $hotel = new Hotels();
    $members = new Members();
    $mailClass = new mailClass();
    $hotel->setHotelId($_REQUEST['id']);
    $hotel->extractor($hotel->getHotelFromId());
    $members->setMemberId($hotel->hotelMemberId());
    $members->extractor($members->getMemberFromId());
    $hotel->setHotelActiveStatus(Libs::getKey("hotel_status_admin", "Active"));
    //INFO: Log
    //$temp_hotel1 = new Hotels();
    //$temp_hotel1->setHotelId($_REQUEST['id']);
    //$temp_hotel1=(array)$temp_hotel1->getHotelFromId();
    //$TransactionLog=new TransactionLog($hotel->hotelId(),Libs::getKey('hotel_sections','Property Details'),'Delete',Sessions::getMemberId(),'hotels',$temp_hotel1[0],'');
    //$TransactionLog->log();
    //$temp_hotel1=null;
    //INFO: Log//
    if ($hotel->changeHotelActiveStatus()) {
        $mailClass->HotelDeactivationRequestCancel($members->memberTitle(), $members->memberFirstName(), $members->memberLastName(), $hotel->hotelName());
        Common::jsonSuccess("Deactivation Cancel request successful");
    } else {
        Common::jsonError("Error");
    }
}
Beispiel #23
0
function deleteClient()
{
    $clients = new Clients();
    $clients->setClientId($_REQUEST['id']);
    if ($clients->deleteClient()) {
        Common::jsonSuccess("Clients Deleted Successfully");
    } else {
        Common::jsonError("Error");
    }
}
function removeRoomImage()
{
    $file = $_REQUEST['image'];
    $file_path = DOC_ROOT . 'uploads/room-gal/' . $file;
    if (file_exists($file_path)) {
        if (unlink($file_path)) {
            Common::jsonSuccess("Room Image Deleted Successfully");
        } else {
            Common::jsonError("Failed To Delete");
        }
    } else {
        Common::jsonError("Error");
    }
}