Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreatetechnician()
 {
     $this->pagename = "Register Technician " . $this->pagename;
     $model = new Users();
     $modelprovider = new Providers();
     $transaction = $model->getDbConnection()->beginTransaction();
     if (isset($_POST['Users'])) {
         $model->attributes = $_POST['Users'];
         $temp = $_POST['Providers'];
         try {
             if ($model->save()) {
                 $authmodel = new AuthAssignment();
                 //$transactionauth=$authmodel->getDbConnection()->beginTransaction();
                 $authmodel->itemname = 'technician';
                 $authmodel->userid = $model->id;
                 if ($authmodel->save()) {
                     $worker = new Workers();
                     //$transactionWorker=$worker->getDbConnection()->beginTransaction();
                     $worker->users_id = $model->id;
                     $worker->providers_id = $temp['id'];
                     if ($worker->save()) {
                         $transaction->commit();
                         //$transactionauth->commit();
                         //$transactionWorker->commit();
                         $this->redirect(array('view', 'id' => $model->id));
                     } else {
                         //$transaction->rollback();
                         //$transactionauth->rollback();
                         //$transactionWorker->rollback();
                     }
                 } else {
                     $transaction->rollback();
                 }
             }
         } catch (Exception $e) {
             $transaction->rollback();
         }
     }
     $this->render('createTechnician', array('model' => $model, 'modelprovider' => $modelprovider, 'providers_array' => CMap::mergeArray(array("" => ""), CHtml::listData(Providers::model()->findAll("id in (select providers_id from workers where users_id=" . Yii::app()->user->id . ")"), "id", 'name'))));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $this->pagename = "Create " . $this->pagename;
     $model = new Providers();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Providers'])) {
         $model->attributes = $_POST['Providers'];
         $this->uploadImageAndUpdateModel($model);
         if ($model->save()) {
             $worker = new Workers();
             $worker->users_id = Yii::app()->user->id;
             $worker->providers_id = $model->id;
             $worker->working_plan = "{}";
             if ($worker->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             } else {
                 print_r($worker->getError(true));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Workers the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Workers::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #4
0
 public function showWorkersTable()
 {
     $data = new Workers();
     $users = $data->getAllWorkersAsArray();
     return View::make('table', array('users' => $users));
 }
Пример #5
0
 /**
  * @method modifiedStatus
  * @access public
  *
  * Modified status of the current record and paste
  * all needed attributes/values
  * save it into base
  *
  * @return (void)
  */
 public function modifiedStatus()
 {
     $model = new Workers();
     $record = $model->findFirst(array(array("jobname" => $this->getWorkJob()->handle())));
     $this->_loger->info("Get last recordId by jobname: " . $record->getId());
     echo "Get last recordId by jobname: " . $record->getId() . "\n";
     $record->status = 2;
     $record->jobend = new MongoDate();
     $record->logresult = $this->getLastLogFile();
     $record->save();
     $this->_loger->info("Work is finished and status in base is change at 2, at recordId: " . $record->getId());
     echo "Work is finished and status in base is change at 2, at recordId: " . $record->getId() . "\n";
 }