Example #1
0
 public function actionEdit()
 {
     $data = Yii::$app->request->post('Record');
     $result = array();
     if (is_numeric($data['id']) && $data['id'] > 0) {
         $model = Record::findOne($data['id']);
         if (!$model) {
             $result['status'] = 0;
             $result['message'] = '未找到该记录';
         }
     } else {
         $model = new Record();
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $result['status'] = 1;
             $result['message'] = '保存成功';
         }
     }
     $errors = $model->getFirstErrors();
     if ($errors) {
         $result['status'] = 0;
         $result['message'] = current($errors);
     }
     return $this->renderJson($result);
 }
 public function store(Request $request)
 {
     $dominio = '.' . $request->input('data.domain');
     $name = $request->input('data.name', null);
     if ($name != null) {
         $record = Record::where('name', '=', $name)->first();
         if ($record != null) {
             return response()->json(['error' => 'record_exist'], 409);
         }
         $name = $request->input('data.name', null) . $dominio;
         //Record table
         $records = new Record();
         $records->domain_id = $request->input('data.domain_id');
         $records->name = $request->input('data.name') . $dominio;
         $records->type = $request->input('data.type');
         if ($request->input('data.content') == '') {
             $records->content = 'ns1.' . $request->input('data.domain') . ' hostmasters.' . $request->input('data.domain') . ' ' . date("Ymd") . "00 28800 7200 604800 86400";
         } else {
             $records->content = $request->input('data.content');
         }
         $records->ttl = $request->input('data.ttl');
         $records->prio = $request->input('data.priority');
         $records->change_date = time();
         $records->auth = '1';
         $records->save();
         return response()->json(['success' => 'record_created'] . 200);
     } else {
         return response()->json(['error' => 'record_exist'], 409);
     }
 }
Example #3
0
 /**
  * Creates a new Record model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Record();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #4
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $a = parent::save($runValidation, $attributes);
     if ($this->public && $this->hash == '' && $a) {
         $download = new \app\models\Download();
         $download->file_id = $this->id;
         $download->company_id = Yii::$app->controller->company;
         $this->hash = $download->id = md5(mt_rand());
         $download->save();
         $a = parent::save($runValidation, $attributes);
     }
     return $a;
 }
Example #5
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $users = User::find()->All();
     parent::save($runValidation, $attributes);
     foreach ($users as $user) {
         if (!UserIncomeMap::findOne(array('user_id' => $user->id, 'itemVatCat_id' => $this->id))) {
             //'user_id', 'itemVatCat_id'
             $model = new UserIncomeMap();
             $attr = array("user_id" => $user->id, "itemVatCat_id" => $this->id, "account_id" => 100);
             $model->attributes = $attr;
             if (!$model->save()) {
                 return false;
             }
         }
     }
 }
 public function actionIndex()
 {
     $model = new Record();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('site/list');
     } else {
         $data = $model->departmentInfo();
         //if max count boys, we doesnt display department
         $department = [];
         foreach ($data as $key => $item) {
             if ($item['boys_count'] != $item['max_boys']) {
                 $department[$key] = $item['name'];
             }
         }
         return $this->render('index', ['model' => $model, 'data' => $data, 'department' => $department]);
     }
 }
 public function actionInsert()
 {
     $session = Yii::$app->session;
     $record = new Record();
     $record->todaydetail = date('md') . date('Hi') . date('s');
     $record->today = $session['today'];
     $record->st_classmark = $session['stu']->st_classmark;
     $record->startday = $session['startday'];
     $record->endday = $session['endday'];
     $record->totalday = $session['totalday'];
     $record->country = $session['country'];
     $record->countryEN = $session['countryEN'];
     $record->st_name = $session['stu']->st_name;
     $record->st_nameEN = $session['st_nameEN'];
     $record->gaokaohao = $session['stu']->st_gaokaohao;
     $record->idcard = $session['idcard'];
     $record->sex = $session['sex'];
     $record->st_year = $session['stu']->st_year;
     $record->st_class = $session['stu']->st_class;
     $record->major = $session['major']->mj_name_zh;
     $record->academy = $session['academy']->ac_name_zh;
     $record->status = '审核中';
     switch ($session['model_id']) {
         case 'baodao':
             $record->model = "报道证明";
             break;
         case 'putongzaidu':
             $record->model = "普通在读证明";
             break;
         case 'chuguoliuxue':
             $record->model = "出国留学在读证明";
             break;
         case 'chuguolvyou':
             $record->model = "出国旅游在读证明";
             break;
         case 'churujing':
             $record->model = "出入境在读证明";
             break;
     }
     $record->save();
     echo "<script>\n            alert ('申请成功,现在返回首页');\n            window.location.href='../web/index.php';\n  \n             </script>";
 }
 public function store(Request $request)
 {
     $name = $request->input('data.name');
     if ($name != null) {
         $dominio = Domain::where('name', '=', $name)->first();
         if ($dominio != null) {
             return response()->json(['error' => 'zone_exists'], 409);
         }
         $master = new Domain();
         $master->name = $request->input('data.name');
         $master->type = $request->input('data.type');
         $master->save();
         $id = $master->id;
         //Get the las insert
         //Insert into Records
         $records = new Record();
         $records->domain_id = $id;
         $records->name = $request->input('data.name');
         $records->type = 'SOA';
         $records->content = 'ns1.' . $request->input('data.name') . ' hostmasters.' . $request->input('data.name') . ' ' . date("Ymd") . "00 28800 7200 604800 86400";
         $records->ttl = '86400';
         $records->prio = '0';
         $records->change_date = time();
         $records->auth = '1';
         $records->save();
         //Insert into Zones
         $zones = new Zone();
         $zones->domain_id = $id;
         $zones->owner = '1';
         $zones->comment = '';
         $zones->zone_templ_id = '0';
         $zones->save();
         return response()->json(['success' => 'zone_created'], 200);
     } else {
         return response()->json(['error' => 'zone_error'], 400);
     }
 }
Example #9
0
 public function save($runValidation = true, $attributes = NULL)
 {
     //$this->mailsend();
     return parent::save($runValidation, $attributes);
 }
 public function addRecord($source = null, $message = "", $level = "muted")
 {
     $record = new Record();
     $record->source_id = $source->id;
     $record->message = $message;
     $record->level = $level;
     return $record->save();
 }
Example #11
0
 public function save($runValidation = true, $attributes = NULL)
 {
     if (!Yii::$app->params['readOnly']) {
         $a = parent::save($runValidation, $attributes);
         Yii::info("Saving Model: " . var_export($this->getErrors(), true));
         return $a;
     } else {
         throw new \Exception(Yii::t('app', 'System is in read only mode.'));
     }
     //401
     return false;
 }