当前位置: 首页>>代码示例>>PHP>>正文


PHP Companies::save方法代码示例

本文整理汇总了PHP中Companies::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Companies::save方法的具体用法?PHP Companies::save怎么用?PHP Companies::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Companies的用法示例。


在下文中一共展示了Companies::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postCreate

 public function postCreate()
 {
     $image = Input::file('url');
     $validator = Validator::make(array('image' => $image), array('image' => 'required|mimes:png,jpeg,gif'), array('mimes' => 'Tipo de imagen inválido, solo se admite los formatos PNG, JPEG, y GIF'));
     if ($validator->fails()) {
         return Redirect::to($this->route . '/create')->with('msg_succes', Lang::get('messages.companies_create_img_err'));
     } else {
         $filename = $this->uploadImage($image);
         $type = '';
         if (Input::get('type') != null) {
             foreach (Input::get('type') as $_t) {
                 # code...
                 $type .= $_t;
             }
         }
         $company = new Companies();
         $company->title = Input::get('title');
         $company->content = Input::get('content');
         $company->address = Input::get('address');
         // $company->contact = Input::get('contact');
         $company->type = $type;
         $company->status = 'draft';
         $company->url = $filename;
         if ($company->save()) {
             return Redirect::to($this->route)->with('msg_success', Lang::get('messages.companies_create', array('title' => $company->title)));
         } else {
             return Redirect::to($this->route)->with('msg_error', Lang::get('messages.companies_create_err', array('title' => $company->title)));
         }
     }
 }
开发者ID:nagyist,项目名称:abge,代码行数:30,代码来源:CompanyController.php

示例2: createAction

 /**
  * Creates a new companie
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "companies", "action" => "index"));
     }
     $companie = new Companies();
     $companie->id = $this->request->getPost("id");
     $companie->name = $this->request->getPost("name");
     if (!$companie->save()) {
         foreach ($companie->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "companies", "action" => "new"));
     }
     $this->flash->success("companie was created successfully");
     return $this->dispatcher->forward(array("controller" => "companies", "action" => "index"));
 }
开发者ID:nhannv56,项目名称:sample2_Phalcon_INVO,代码行数:20,代码来源:CompaniesController.php

示例3: createAction

 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->forward("companies/index");
     }
     $companies = new Companies();
     $companies->name = $this->request->getPost("name", "striptags");
     $companies->telephone = $this->request->getPost("telephone", "striptags");
     $companies->address = $this->request->getPost("address", "striptags");
     $companies->city = $this->request->getPost("city", "striptags");
     if (!$companies->save()) {
         foreach ($companies->getMessages() as $message) {
             $this->flash->error((string) $message);
         }
         return $this->forward("companies/new");
     }
     $this->flash->success("Company was created successfully");
     return $this->forward("companies/index");
 }
开发者ID:Rho1and0,项目名称:invo,代码行数:19,代码来源:CompaniesController.php

示例4: implode

        $vals['found_date'] = Times::dateConvert($_POST['FoundDate']);
    }
    if (isset($_POST['company']['main_market'])) {
        $mainmarket = implode(",", $_POST['company']['main_market']);
        $vals['main_market'] = $mainmarket;
    }
    if (isset($_POST['data']['username'])) {
        $username = trim($_POST['data']['username']);
        $user_info = $member->checkUserExist($username, true);
        if ($user_info) {
            $vals['member_id'] = $member->info['id'];
        }
    }
    if (!empty($company_id)) {
        $vals['modified'] = $time_stamp;
        $result = $company->save($vals, "update", $company_id);
    } else {
        $vals['created'] = $vals['modified'] = $time_stamp;
        $result = $company->save($vals);
    }
    if (!$result) {
        flash();
    }
}
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);
    }
    if ($do == "search") {
        if (!empty($_GET['member']['username'])) {
开发者ID:renduples,项目名称:alibtob,代码行数:31,代码来源:company.php

示例5: createAction

 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->_forward("companies/index");
     }
     $companies = new Companies();
     $companies->id = $this->request->getPost("id", "int");
     $companies->name = $this->request->getPost("name");
     $companies->telephone = $this->request->getPost("telephone");
     $companies->address = $this->request->getPost("address");
     $companies->city = $this->request->getPost("city");
     $companies->name = strip_tags($companies->name);
     $companies->telephone = strip_tags($companies->telephone);
     $companies->address = strip_tags($companies->address);
     $companies->city = strip_tags($companies->city);
     if (!$companies->save()) {
         foreach ($companies->getMessages() as $message) {
             Flash::error((string) $message, "alert alert-error");
         }
         return $this->_forward("companies/new");
     } else {
         Flash::success("companies was created successfully", "alert alert-success");
         return $this->_forward("companies/index");
     }
 }
开发者ID:racklin,项目名称:invo,代码行数:25,代码来源:CompaniesController.php

示例6: actionIndex

 /**
  * \brief Основная страница входа, подргружает Login-Form
  */
 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('clients_page'));
     }
     $company = new Companies();
     $model = new Users();
     $model->setScenario('registration');
     if (isset($_POST['Users'])) {
         $model->attributes = $_POST['Users'];
         $model->status = 'none';
         $company->name = $_POST['Users']['company_name'];
         if (isset($_POST['ajax']) && $_POST['ajax'] == 'check-registration-form') {
             echo CActiveForm::validate($model);
             Yii::app()->end();
         }
         if ($company->save()) {
             $model->company_id = $company->id;
             if ($model->save()) {
                 $role = new UsersRoles();
                 $role->user_id = $model->id;
                 $role->itemname = 'admin';
                 $role->save();
                 //создание настроек для клиентов
                 $default_settings = array('Groups' => array('Главная группа', 'Потенциальные клиенты', 'Реальные клиенты', 'Постоянные клиенты', 'Партнеры'), 'Goals' => array('Нет цели', 'Создать интерес', 'Заключить сделку', 'Новые сделки'), 'Sources' => array('Нет источника', 'Сайт', 'Соц. сети', 'SEO', 'Листовки', 'Доска объявлений'), 'Cityes' => array('Нет города', 'Москва', 'Пермь', 'Санкт-Петербуг', 'Екатеринбург', 'Новосибирск'));
                 foreach ($default_settings as $key => $default_values) {
                     $modelName = 'Clients' . $key;
                     foreach ($default_values as $val) {
                         $modelSettings = new $modelName();
                         $modelSettings->name = $val;
                         $modelSettings->company_id = $company->id;
                         $modelSettings->save();
                     }
                 }
                 //создание настроек для действий
                 $default_settings = array('Types' => array('Действие не указано', 'Звонок', 'Встреча', 'Предложение', 'Акция'));
                 foreach ($default_settings as $key => $default_values) {
                     $modelName = 'Actions' . $key;
                     foreach ($default_values as $val) {
                         $modelSettings = new $modelName();
                         $modelSettings->name = $val;
                         $modelSettings->company_id = $company->id;
                         $modelSettings->save();
                     }
                 }
                 //создание настроек для сделок
                 $default_settings = array('Categories' => array('Нет категории', 'Категория сделки #1', 'Категория сделки #2', 'Категория сделки #3'));
                 foreach ($default_settings as $key => $default_values) {
                     $modelName = 'Deals' . $key;
                     foreach ($default_values as $val) {
                         $modelSettings = new $modelName();
                         $modelSettings->name = $val;
                         $modelSettings->company_id = $company->id;
                         $modelSettings->save();
                     }
                 }
                 $activated = new Activations();
                 $activated->setAttributes(array('type' => 'registration', 'add_data' => '', 'user_id' => $model->id, 'key' => substr(preg_replace('/[oO0Il1]/i', '', md5(rand() . rand() . rand() . time())), 0, 24), 'date' => new CDbExpression('NOW()')));
                 if ($activated->save()) {
                     $link = 'http://' . $_SERVER['HTTP_HOST'] . '/page/activation/key/' . $activated->key;
                     $email = Yii::app()->email;
                     $email->AddAddress($model->email);
                     $email->Subject = 'Подтверждение регистрации';
                     $email->Body = 'Приветствуем, ' . $model->first_name . ' ' . $model->second_name . '!<br/>
                                     Вы зарегистрировались на сайте inclient.ru. <br/>
                                     Пожалуйста, подтвердите регистрацию учетной записи перейдя по ' . CHtml::link('ссылке', $link) . ' или просто нажмите здесь ' . $link . '. <br/>
                                     Это необходимо для того, чтобы воспользоваться всеми возможностями сайта.<br/>
                                     Если в течении 30 дней Вы не подтвердите регистрацию, то Ваш аккаунт будет удален.<br/>
                                     <br/>
                                     С уважением, Администрация INCLIENT.RU<br/>
                                     <br/>
                                     Если у вас возникнут вопросы напишите в поддержку <br/>
                                     support@inclient.ru';
                     $email->send();
                 }
                 $login = new LoginForm();
                 $login->email = $_POST['Users']['email'];
                 $login->password = $_POST['Users']['password'];
                 if ($login->login()) {
                     $this->redirect(array('clients_page'));
                 }
             }
         }
     }
     $this->render('registration', array('model' => $model));
 }
开发者ID:ArseniyDyupin,项目名称:SimpleCRM2,代码行数:89,代码来源:PageController.php

示例7: createEmptyCompany

    /**
     * Create Empty company without users
     * @param $fedId
     * @param $newCompanyName
     * @param $impVendorInfo
     * @return Clients
     */
    public static function createEmptyCompany($fedId, $newCompanyName, $impVendorInfo = null)
    {
        $client = new Clients;

        // begin transaction
        $transaction = Yii::app()->db->beginTransaction();
        try {
            $company = new Companies;
            $project = new Projects;
            $companyAdreses = new CompanyAddresses;
            //$usersClientList = new UsersClientList;

            $company->Company_Name = $newCompanyName;
            $company->Company_Fed_ID = $fedId;
            if (preg_match('/^(\d{2}\-\d{7})|(\d{3}\-\d{2}\-\d{4})$/', $company->Company_Fed_ID)) {
                //usual w9 do nothing
            }

            if (preg_match('/^(IN[-]\d{7})$/', $company->Company_Fed_ID)) {
            //international w9
                $company->Temp_Fed_ID_Flag = 'N';

            }
            if (preg_match('/^(T0[-]\d{7})$/', $company->Company_Fed_ID)) {
                //international w9
                $company->Temp_Fed_ID_Flag = 'T';
            }

            $company->Auth_Code = Helper::generatePassword();

            $company->save();


            $company_adress = new Addresses;

            if ($impVendorInfo) {
                $company_adress = new Addresses;
                $company_adress->Address1 = $impVendorInfo['address'];
                $company_adress->City = $impVendorInfo['city'];
                $company_adress->State = $impVendorInfo['state'];
                $company_adress->ZIP = $impVendorInfo['zip'];
                if ($company_adress->validate()) {
                    $company_adress->save();
                } else {
                    $company_adress = new Addresses;
                    $company_adress->save();
                }
            }

            $company_adress->save();

            $companyAdreses->Company_ID = $company->Company_ID;
            $companyAdreses->Address_ID = $company_adress->Address_ID ? $company_adress->Address_ID : 0;
            $companyAdreses->save();

            $client->Company_ID = $company->Company_ID;
            $client->Client_Type = 1;
            $client->Client_Number = 1;
            $client->save();

            //create client project
            $project->Client_ID = $client->Client_ID;
            $project->Project_Name = "Corporate";
            $project->Project_Description = "Description of the Project";
            $project->PO_Starting_Number = Projects::DEFAULT_PO_STARTING_NUMBER;
            $project->Ck_Req_Starting_Numb = Projects::DEFAULT_CKRQ_STARTING_NUMBER;
            $project->save();

            $transaction->commit();
        } catch(Exception $e) {
            $transaction->rollback();
        }

        return $client;
    }
开发者ID:ranvijayj,项目名称:htmlasa,代码行数:82,代码来源:Companies.php

示例8: actionCreate

 /**
  * Creates a new model.
  * @return create view
  */
 public function actionCreate()
 {
     // check if user has permissions to createCompanies
     if (Yii::app()->user->checkAccess('createCompanies')) {
         // object models
         $model = new Companies();
         $address = new Address();
         // if Companies form exist and was sent
         if (isset($_POST['Companies'])) {
             $model->attributes = $_POST['Companies'];
             $address->attributes = $_POST['Address'];
             // validate models
             $valid = $address->validate();
             $valid = $model->validate() && $valid;
             // validation results
             if ($valid) {
                 // save address
                 $address->save(false);
                 $model->address_id = $address->primaryKey;
                 // save company model
                 if ($model->save(false)) {
                     // create object relation and save
                     $companiesHasUsers = new CompaniesHasUsers();
                     $companiesHasUsers->company_id = $model->company_id;
                     $companiesHasUsers->user_id = Yii::app()->user->id;
                     if ($companiesHasUsers->save(false)) {
                         // save log
                         $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CompanyCreated', 'log_resourceid' => $model->primaryKey, 'log_type' => Logs::LOG_CREATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id);
                         Logs::model()->saveLog($attributes);
                         // to prevent F5 keypress, redirect to view detail page
                         $this->redirect(array('view', 'id' => $model->company_id));
                     }
                 }
             }
         }
         $this->render('create', array('model' => $model, 'address' => $address));
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
开发者ID:lanzelotik,项目名称:celestic-community,代码行数:44,代码来源:CompaniesController.php

示例9: doSave

 /**
  * Show the POST form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function doSave()
 {
     $validator = Validator::make(Input::all(), Companies::$rules);
     if ($validator->passes()) {
         $id = Input::get('id');
         if (isset($id) && $id > 0) {
             $company = Companies::find($id);
         } else {
             $company = new Companies();
         }
         $company->name = Input::get('name');
         $company->description = Input::get('description');
         $company->city_id = Input::get('city_id');
         $company->phone = Input::get('phone');
         $company->email = Input::get('email');
         $company->web_site = Input::get('web_site');
         $company->user_id = Auth::user()->id;
         $company->save();
         return Redirect::route('company-list')->with('message', 'Company has been added/changed.');
     } else {
         return Redirect::route('company-edit')->with('message', 'The following errors occurred')->withErrors($validator)->withInput();
     }
 }
开发者ID:sergey-donchenko,项目名称:hr-agency,代码行数:29,代码来源:CompaniesController.php


注:本文中的Companies::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。