/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), array('name' => 'required|min:3|unique:services,name'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $pets = Input::get('pets');
     $service = new Services();
     $service->name = Input::get('name');
     $service->save();
     $service->serviciablePets()->attach(array_flatten($pets));
     return Redirect::to('services');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Services();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Services'])) {
         $model->attributes = $_POST['Services'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function getSave()
 {
     $id = Input::get('id');
     if ($id) {
         $services = Services::find($id);
         $services->name = Input::get('name');
         $services->price = Input::get('price');
         $services->save();
         Session::flash('message', 'The records are updated successfully');
     } else {
         $services = new Services();
         $services->name = Input::get('name');
         $services->price = Input::get('price');
         $services->save();
         Session::flash('message', 'The records are inserted successfully');
     }
     return Redirect::to('services');
 }
Exemple #4
0
setvar("ServiceTypes", $typeoption->get_cache_type("service_type"));
if (isset($_POST['save_client'])) {
    if (!empty($_POST['data']['setting'])) {
        $updated = $setting->replace($_POST['data']['setting'], 1);
        if ($updated) {
            $cache->writeCache("setting", "setting");
            flash("success");
        }
    }
    flash();
}
if (isset($_POST['save']) && !empty($_POST['data']['service'])) {
    $vals = array();
    $vals = $_POST['data']['service'];
    $vals['modified'] = $time_stamp;
    $result = $service->save($vals, "update", $_POST['id']);
    if (!empty($vals['revert_content'])) {
        $datas = array("actor" => $adminer_info['last_name'], "action" => L("feed_revert", "tpl"), "do" => L("feed_problem", "tpl"), "subject" => '<a href="index.php?do=service&action=detail&id=' . $_POST['id'] . '">' . $vals['title'] . '</a>');
        $sql = "INSERT INTO {$tb_prefix}feeds (type_id,type,member_id,username,data,created,modified,revert_date) VALUE ('1','service'," . $current_adminer_id . ",'" . $adminer_info['last_name'] . "','" . serialize($datas) . "'," . $time_stamp . "," . $time_stamp . "," . $time_stamp . ")";
        $pdb->Execute($sql);
    }
    if (!$result) {
        flash();
    }
}
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if (!empty($_GET['id'])) {
        $id = intval($_GET['id']);
    }
    if ($do == "client") {
Exemple #5
0
 public function actionAddService()
 {
     $id = (int) Yii::app()->request->getParam('id', 0);
     $modelRequest = $this->isReal($id)['model'];
     $eventName = Yii::app()->request->getParam('m', false);
     $returnArray = array();
     $status = false;
     $msg = '';
     if ($eventName) {
         $model = new Services();
         $model->name = $eventName;
         $model->created_by = Yii::app()->user->getInfo();
         if ($modelRequest != null) {
             $model->request_id = $modelRequest->id;
         }
         if ($model->save()) {
             $status = true;
             $msg = 'Successfully done';
             //                $criteria = new CDbCriteria();
             //                $criteria->addCondition('created_by = '.Yii::app()->user->getInfo());
             //                $criteria->addCondition('id != '.$model->id);
             //                $modelArray = Services::model()->findAll($criteria);
             //                foreach ($modelArray as $model) {
             //                    $model->request_id = null;
             //                    $model->save();
             //                }
         } else {
             $msg = $model->getErrors();
         }
     }
     $returnArray['status'] = $status;
     $returnArray['msg'] = $msg;
     header('Content-Type: application/json');
     $return = json_encode($returnArray);
     echo $return;
     Yii::app()->end();
 }