Exemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Provider();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Provider'])) {
         $model->attributes = $_POST['Provider'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $provider = new Provider();
     $data = Input::all();
     // Revisamos si la data es válido
     if ($provider->isValid($data)) {
         // Si la data es valida se la asignamos al provider
         $provider->fill($data);
         // Guardamos el provider
         $provider->save();
         return Redirect::to('admin/provider')->with('success_message', 'El registro ha sido ingresado correctamente.')->withInput();
     } else {
         // En caso de error regresa a la acción create con los datos y los errores encontrados
         return Redirect::back()->withInput()->withErrors($provider->errors);
     }
 }
Exemplo n.º 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Provider();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Provider'])) {
         $model->attributes = $_POST['Provider'];
         //$model->active = 1;
         if ($model->save()) {
             if (!empty($_POST['yt1'])) {
                 Yii::app()->user->setFlash('provider-created', "¡El proveedor <b><i>&quot;{$model->name}&quot;</i></b> fue creado exitosamente!");
                 $this->redirect(array('create'));
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 protected function saveProvider($user = null, $service = null)
 {
     if ($user and $service) {
         $provider = new Provider();
         $provider->user_id = $user->id;
         $provider->industry_id = $service->industry_id;
         $provider->loc_id = $user->details->loc_id;
         $provider->legal_form = 'freelancer';
         $provider->type = 'service_provider';
         $provider->department_type = 'hq';
         $provider->status = 'active';
         $provider->registration_time = date('Y-m-d H:i:s');
         if ($provider->save()) {
             $user->is_provider = 1;
             $user->save();
             // provider Contact
             $providerContact = new \common\models\ProviderContact();
             $providerContact->provider_id = $provider->id;
             $providerContact->contact_type = 'e-mail';
             $providerContact->value = $user->email;
             $providerContact->save();
             // provider Industry
             $providerIndustry = new \common\models\ProviderIndustries();
             $providerIndustry->provider_id = $provider->id;
             $providerIndustry->industry_id = $service->industry_id;
             $providerIndustry->main = 1;
             if ($providerIndustry->save()) {
                 $proserv = new \common\models\ProviderServices();
                 $proserv->provider_industry_id = $providerIndustry->id;
                 $proserv->provider_id = $provider->id;
                 $proserv->industry_id = $service->industry_id;
                 $proserv->service_id = $service->id;
                 $proserv->is_set = 1;
                 $proserv->update_time = date('Y-m-d H:i:s');
                 $proserv->save();
             }
             // provider Industry Terms
             $providerIndustryTerm = new \common\models\ProviderIndustryTerms();
             $providerIndustryTerm->provider_industry_id = $providerIndustry->id;
             $providerIndustryTerm->update_time = date('Y-m-d H:i:s');
             $providerIndustryTerm->save();
             // provider Language
             $providerLanguage = new \common\models\ProviderLanguages();
             $providerLanguage->provider_id = $provider->id;
             $providerLanguage->lang_code = 'SR';
             $providerLanguage->save();
             // provider Portfolio
             $providerPortfolio = new \common\models\ProviderPortfolio();
             $providerPortfolio->provider_id = $provider->id;
             $providerPortfolio->name = 'Moj portfolio';
             $providerPortfolio->save();
             // provider Terms
             $providerTerms = new \common\models\ProviderTerms();
             $providerTerms->provider_id = $provider->id;
             $providerTerms->update_time = date('Y-m-d H:i:s');
             $providerTerms->save();
             // provider Notifications
             $providerNotifications = new \common\models\ProviderNotifications();
             $providerNotifications->provider_id = $provider->id;
             $providerNotifications->notification_type = 'matching';
             $providerNotifications->time = date('Y-m-d H:i:s');
             $providerNotifications->save();
             return $proserv;
         }
     }
     return false;
 }
     foreach ($license->getConsortiumList() as $display) {
         if ($_GET['shortName'] == $display['name']) {
             echo "<option value='" . $display['consortiumID'] . "' selected>" . $display['name'] . "</option>";
         } else {
             echo "<option value='" . $display['consortiumID'] . "'>" . $display['name'] . "</option>";
         }
     }
     echo "</select>";
     break;
 case 'addProvider':
     if (isset($_GET['shortName']) && $_GET['shortName'] != '') {
         $provider = new Provider();
         $provider->providerID = '';
         $provider->shortName = $_GET['shortName'];
         try {
             $provider->save();
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
     echo "<select name='licenseProviderID' id='licenseProviderID'>";
     echo "<option value=''></option>";
     $displayArray = array();
     $display = array();
     $provider = new Provider();
     $displayArray = $provider->allAsArray();
     foreach ($displayArray as $display) {
         if ($_GET['shortName'] == $display['shortName']) {
             echo "<option value='" . $display['providerID'] . "' selected>" . $display['shortName'] . "</option>";
         } else {
             echo "<option value='" . $display['providerID'] . "'>" . $display['shortName'] . "</option>";
Exemplo n.º 6
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionImport()
 {
     $model = new Provider();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Provider'])) {
         if (!empty($_FILES)) {
             $tempFile = $_FILES['Provider']['tmp_name']['fileImport'];
             $fileTypes = array('xls', 'xlsx');
             // File extensions
             $fileParts = pathinfo($_FILES['Provider']['name']['fileImport']);
             if (in_array(@$fileParts['extension'], $fileTypes)) {
                 Yii::import('ext.heart.excel.EHeartExcel', true);
                 EHeartExcel::init();
                 $inputFileType = PHPExcel_IOFactory::identify($tempFile);
                 $objReader = PHPExcel_IOFactory::createReader($inputFileType);
                 $objPHPExcel = $objReader->load($tempFile);
                 $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
                 $baseRow = 2;
                 $inserted = 0;
                 $read_status = false;
                 while (!empty($sheetData[$baseRow]['A'])) {
                     $read_status = true;
                     //$provider_id=  $sheetData[$baseRow]['A'];
                     $name = $sheetData[$baseRow]['B'];
                     $model2 = new Provider();
                     //$model2->provider_id=  $provider_id;
                     $model2->name = $name;
                     try {
                         if ($model2->save()) {
                             $inserted++;
                         }
                     } catch (Exception $e) {
                         Yii::app()->user->setFlash('error', "{$e->getMessage()}");
                         //$this->refresh();
                     }
                     $baseRow++;
                 }
                 Yii::app()->user->setFlash('success', $inserted . ' row inserted');
             } else {
                 Yii::app()->user->setFlash('warning', 'Wrong file type (xlsx, xls, and ods only)');
             }
         }
         $this->render('admin', array('model' => $model));
     } else {
         $this->render('admin', array('model' => $model));
     }
 }
Exemplo n.º 7
0
 public function actionRegisterProvider()
 {
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
     $request = Yii::app()->request;
     try {
         $name = $request->getPost('name');
         $email = $request->getPost('email');
         $phone = $request->getPost('phone');
         $address = $request->getPost('address');
         $provider = new Provider();
         $provider->email = $email;
         $provider->phone = $phone;
         $provider->provider_name = $name;
         $provider->provider_address = $address;
         $token = StringHelper::generateToken(5, 25);
         $provider->token = $token;
         if ($provider->save(FALSE)) {
             $subject = 'Kích hoạt tài khoản provider Meboo của bạn';
             $to_email = $email;
             $from_email = '*****@*****.**';
             $from_name = 'Hỗ trợ Meboo';
             $message = 'Bấm vào đây để kích hoạt tài khoản Provider Meboo của bạn: http://doitac.meboo.vn/user/activate?token=' . $token;
             MailQueue::model()->addMailQueue($message, $from_email, $from_name, $to_email, $subject);
             ResponseHelper::JsonReturnSuccess('', 'Success');
         } else {
             ResponseHelper::JsonReturnError('', 'Error');
         }
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage(), 'Error');
     }
 }
Exemplo n.º 8
0
 public function add($post)
 {
     $model = new Provider();
     $model->setAttributes($post);
     $model->active = 0;
     //MailQueue::model()->add();
     if ($model->save(FALSE)) {
         MailQueue::model()->addMailQueue('Có một đơn vị cung cấp dịch vụ y tế đã đăng ký tới Meboo', '*****@*****.**', 'meboo admin', '*****@*****.**', 'Có một đơn đặt hàng mới dịch vụ medlatec');
         return TRUE;
     }
     return FALSE;
 }