public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Company::create([]);
     }
 }
 public function run()
 {
     $faker = Faker::create();
     Company::deleteAll();
     foreach (range(1, 10) as $index) {
         Company::create(['title' => $faker->company, 'address' => $faker->streetAddress, 'phone' => $faker->phoneNumber]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::only('rut', 'fancy_name', 'description', 'adress', 'city', 'location', 'phone_number');
     $company = Company::create($input);
     $products = Input::only("productos");
     //Insert products in pivot table company_product
     Event::fire('company.created', [$products, $company]);
     return Redirect::action('AdminsController@index');
 }
Example #4
0
 /**
  * Run the user seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('companies')->delete();
     DB::table('users_companies')->delete();
     $visible = Company::create(array('name' => 'Visible', 'user_id' => 1));
     $invisible = Company::create(array('name' => 'Invisible', 'user_id' => 1));
     UserCompany::create(array('company_id' => $visible->id, 'user_id' => 1));
     UserCompany::create(array('company_id' => $invisible->id, 'user_id' => 2));
 }
Example #5
0
 public function store()
 {
     $input = Input::all();
     $validator = Validator::make($input, $this->rules);
     if ($validator->passes()) {
         $company = Company::create(array('user_id' => Sentry::getUser()->id, 'name' => $input['name']));
         UserCompany::create(array('company_id' => $company->id, 'user_id' => $company->user_id));
         Session::flash('success', trans('company.create.success', array('name' => $company->name)));
         return Redirect::route('company.show', array('id' => $company->id));
     }
     return Redirect::back()->withErrors($validator)->withInput($input);
 }
 public function addCustCompany()
 {
     $comp = Company::get();
     $isAdded = FALSE;
     $validInput = TRUE;
     $regex = "/^[a-zA-Z\\'\\-\\.\\,]+( [a-zA-Z\\'\\-\\.\\,]+)*\$/";
     $regexName = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     $regexHouse = "/[0-9a-zA-Z\\-\\s]+\$/";
     $regexStreet = "/^[a-zA-Z0-9\\'\\-\\.]+( [a-zA-Z0-9\\'\\-\\.]+)*\$/";
     $regexBarangay = "/^[a-zA-Z0-9\\'\\-\\.]+( [a-zA-Z0-9\\'\\-\\.]+)*\$/";
     $regexCity = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     $regexZip = "/^[0-9]+\$/";
     $regexProvince = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     if (!trim(Input::get('addComName')) == '' && !trim(Input::get('addConPerson')) == '' && !trim(Input::get('addCustCompanyHouseNo')) == '' && !trim(Input::get('addComEmailAddress')) == '' && !trim(Input::get('addCustCompanyStreet')) == '' && !trim(Input::get('addCustCompanyCity')) == '' && !trim(Input::get('addCel')) == '') {
         $validInput = TRUE;
         if (preg_match($regex, Input::get('addComName')) && preg_match($regexName, Input::get('addConPerson')) && preg_match($regexHouse, Input::get('addCustCompanyHouseNo')) && !!filter_var(Input::get('addComEmailAddress'), FILTER_VALIDATE_EMAIL) && preg_match($regexStreet, Input::get('addCustCompanyStreet')) && preg_match($regexCity, Input::get('addCustCompanyCity'))) {
             $validInput = TRUE;
             if (!trim(Input::get('addCustCompanyZipCode')) == '' || !trim(Input::get('addCustCompanyProvince')) == '' || !trim(Input::get('addCustCompanyBarangay')) == '') {
                 if (preg_match($regexZip, Input::get('addCustCompanyZipCode')) || preg_match($regexProvince, Input::get('addCustCompanyProvince')) || preg_match($regexBarangay, Input::get('addCustCompanyBarangay'))) {
                     $validInput = TRUE;
                 } else {
                     $validInput = FALSE;
                 }
             }
         } else {
             $validInput = FALSE;
         }
     } else {
         $validInput = FALSE;
     }
     $count = DB::table('tblCustCompany')->select('tblCustCompany.strCustCompanyEmailAddress')->where('tblCustCompany.strCustCompanyEmailAddress', '=', trim(Input::get('addComEmailAddress')))->count();
     $count2 = DB::table('tblCustCompany')->select('tblCustCompany.strCustCompanyCPNumber')->where('tblCustCompany.strCustCompanyCPNumber', '=', trim(Input::get('addCel')))->count();
     if ($count > 0 || $count2 > 0) {
         $isAdded = TRUE;
     } else {
         foreach ($comp as $comp) {
             if (strcasecmp($comp->strCustCompanyName, trim(Input::get('addComName'))) == 0 || strcasecmp($comp->strCustContactPerson, trim(Input::get('addConPerson'))) == 0) {
                 $isAdded = TRUE;
             }
         }
     }
     if ($validInput) {
         if (!$isAdded) {
             $company = Company::create(array('strCustCompanyID' => Input::get('addComID'), 'strCustCompanyName' => trim(Input::get('addComName')), 'strCustCompanyHouseNo' => trim(Input::get('addCustCompanyHouseNo')), 'strCustCompanyStreet' => trim(Input::get('addCustCompanyStreet')), 'strCustCompanyBarangay' => trim(Input::get('addCustCompanyBarangay')), 'strCustCompanyCity' => trim(Input::get('addCustCompanyCity')), 'strCustCompanyProvince' => trim(Input::get('addCustCompanyProvince')), 'strCustCompanyZipCode' => trim(Input::get('addCustCompanyZipCode')), 'strCustContactPerson' => trim(Input::get('addConPerson')), 'strCustCompanyEmailAddress' => trim(Input::get('addComEmailAddress')), 'strCustCompanyCPNumber' => trim(Input::get('addCel')), 'strCustCompanyCPNumberAlt' => trim(Input::get('addCelAlt')), 'strCustCompanyTelNumber' => trim(Input::get('addPhone')), 'strCustCompanyFaxNumber' => trim(Input::get('addFax')), 'boolIsActive' => 1));
             $company->save();
             return Redirect::to('/maintenance/customerCompany?success=true');
         } else {
             return Redirect::to('/maintenance/customerCompany?success=duplicate');
         }
     } else {
         return Redirect::to('/maintenance/customerCompany?input=invalid');
     }
 }
Example #7
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Eloquent::unguard();
        DB::table('companies')->delete();
        DB::table('items')->delete();
        DB::table('categories')->delete();
        $territory = Territory::where('name', 'Stockholms län')->where('county', '01')->first();
        $company1 = Company::create(array('id' => 1, 'name' => '北欧工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '啊发扩大浪费大斗进发觉啦地方', 'established_year' => '2011'));
        $company2 = Company::create(array('id' => 2, 'name' => '阿呆姆斯工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '饿我热哦我iooewpp', 'established_year' => '2013'));
        $item1 = Item::create(array('id' => 1, 'company_id' => 1, 'name' => 'Kayala投资项目', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 20000000));
        $item2 = Item::create(array('id' => 2, 'company_id' => 1, 'name' => '棕熊城堡出售', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 30000000, 'max_investment' => 30000000));
        $item3 = Item::create(array('id' => 3, 'company_id' => 2, 'name' => '布鲁艾尔空气净化器', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 10000000, 'max_investment' => 10000000));
        $item4 = Item::create(array('id' => 4, 'company_id' => 2, 'name' => 'volvo公司转让', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 250000000, 'max_investment' => 250000000));
        Category::create(array('id' => 1, 'name' => '融资项目'));
        Category::create(array('id' => 2, 'name' => '房产出售'));
        Category::create(array('id' => 3, 'name' => '产品推广'));
        Category::create(array('id' => 4, 'name' => '公司转让'));
        Category::create(array('id' => 5, 'name' => '技术出售'));
        Category::create(array('id' => 6, 'name' => '文化, 媒体, 旅游'));
        CompanyCategory::create(array('id' => 1, 'company_id' => 1, 'category_id' => 6));
        CompanyCategory::create(array('id' => 2, 'company_id' => 2, 'category_id' => 6));
        ItemCategory::create(array('id' => 1, 'item_id' => 1, 'category_id' => 1));
        ItemCategory::create(array('id' => 2, 'item_id' => 1, 'category_id' => 2));
        ItemCategory::create(array('id' => 3, 'item_id' => 2, 'category_id' => 2));
        ItemCategory::create(array('id' => 4, 'item_id' => 3, 'category_id' => 4));
        ItemCategory::create(array('id' => 5, 'item_id' => 3, 'category_id' => 5));
        ItemCategory::create(array('id' => 6, 'item_id' => 3, 'category_id' => 6));
        ItemCategory::create(array('id' => 7, 'item_id' => 4, 'category_id' => 3));
        ItemCategory::create(array('id' => 8, 'item_id' => 4, 'category_id' => 5));
        Tag::create(array('id' => 1, 'name' => '回报率高'));
        Tag::create(array('id' => 2, 'name' => '绿色环保'));
        Tag::create(array('id' => 3, 'name' => '市场巨大'));
        Tag::create(array('id' => 4, 'name' => '用途广'));
        Tag::create(array('id' => 5, 'name' => '历史悠久'));
        Tag::create(array('id' => 6, 'name' => '可自雇'));
        Tag::create(array('id' => 7, 'name' => 'PM2.5'));
        ItemTag::create(array('id' => 1, 'tag_id' => 1, 'item_id' => 1));
        ItemTag::create(array('id' => 2, 'tag_id' => 2, 'item_id' => 1));
        ItemTag::create(array('id' => 3, 'tag_id' => 3, 'item_id' => 1));
        ItemTag::create(array('id' => 4, 'tag_id' => 2, 'item_id' => 2));
        ItemTag::create(array('id' => 5, 'tag_id' => 3, 'item_id' => 2));
        ItemTag::create(array('id' => 6, 'tag_id' => 4, 'item_id' => 2));
        ItemTag::create(array('id' => 7, 'tag_id' => 5, 'item_id' => 3));
        ItemTag::create(array('id' => 8, 'tag_id' => 6, 'item_id' => 3));
        ItemTag::create(array('id' => 9, 'tag_id' => 7, 'item_id' => 3));
        ItemTag::create(array('id' => 10, 'tag_id' => 3, 'item_id' => 4));
        ItemTag::create(array('id' => 11, 'tag_id' => 6, 'item_id' => 4));
    }
Example #8
0
 /**
  * Execute the console command
  *
  * @return void
  */
 public function fire()
 {
     $allowed_types = array('array', 'boolean', 'integer', 'number', 'null', 'object', 'string');
     $cluster = Cluster::where('clustername', '=', $this->option('cluster'))->first();
     if (!isset($cluster)) {
         $this->comment("This cluster doesn't exist.");
         return;
     }
     do {
         // get company name
         do {
             $name = $this->ask("Company name : ");
             if (empty($name)) {
                 $this->comment("Your company name is empty.");
             }
         } while (empty($name));
         // check if a company with this name and cluster already exists
         $company = Company::byName($cluster, $name)->first();
         if (isset($company)) {
             $this->comment("A company with this name already exists, please choose another one.");
         }
     } while (isset($company));
     // get company logo url
     do {
         $logo_url = $this->ask("Logo url: ");
         if (empty($logo_url)) {
             $this->comment("Your logo url is empty.");
         }
     } while (empty($logo_url));
     $domains = array();
     // get company domains
     $add_domains = $this->ask("Do you want to add any domains (like: '@flatturtle.com')? [Y]/n") ? 0 : 1;
     while ($add_domains) {
         $domain = $this->ask("Domain: ");
         if (empty($domain)) {
             $this->comment("Your domain is empty.");
         }
         array_push($domains, $domain);
         $add_domains = $this->ask("Do you want to add more domains (like: '@flatturtle.com')? [Y]/n") ? 0 : 1;
     }
     $company = Company::create(array("name" => $name, "logo_url" => $logo_url, "cluster_id" => $cluster->id, "domains" => json_encode($domains)));
     $this->info("Company '{$company->name}' has been saved.");
     return;
 }
 function createCompany(Cluster $cluster, $name)
 {
     if (!strcmp($cluster->clustername, Auth::user()->clustername) || Auth::user()->isAdmin()) {
         // todo pull up method and put it in basecontroller
         $content = Request::instance()->getContent();
         if (empty($content)) {
             return $this->_sendErrorMessage(400, "Payload.Null", "Received payload is empty.");
         }
         if (Input::json() == null) {
             return $this->_sendErrorMessage(400, "Payload.Invalid", "Received payload is invalid.");
         }
         $validator = Validator::make(Input::json()->all(), array("name" => "required", "logo_url" => "required|url"));
         if (!$validator->fails()) {
             $company_name = Input::json()->get('name');
             $company = Company::byName($cluster->id, $company_name)->first();
             // if no domains are included make it an empty array
             $domains = Input::json()->get('domains');
             if (!isset($domains)) {
                 $domains = array();
             }
             //
             $data = array("name" => $company_name, "logo_url" => Input::json()->get('logo_url'), "domains" => json_encode($domains));
             if (isset($company)) {
                 // if the company already exists -> update
                 $company->fill($data);
                 if ($company->save()) {
                     return $company;
                 }
             } else {
                 //otherwise we create a new one
                 $data["cluster_id"] = $cluster->id;
                 return Company::create($data);
             }
         } else {
             return $this->_sendValidationErrorMessage($validator);
         }
     } else {
         return $this->_sendErrorMessage(403, "WriteAccessForbiden", "You can't create things on behalf of another user.");
     }
 }
Example #10
0
 public function run()
 {
     Company::create(['rut' => "9-1", 'adress' => "Dirección", 'city' => "Santiago", 'location' => "San Miguel", 'phone_number' => "5544525", 'fancy_name' => "Jumbo", 'description' => "Comercializado de Productos Jumbo"]);
 }
Example #11
0
 function company($condition = FALSE, $id = FALSE)
 {
     switch ($condition) {
         case 'create':
             if ($_POST) {
                 unset($_POST['send']);
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $company = Company::create($_POST);
                 $companyid = Company::last();
                 $new_company_reference = $_POST['reference'] + 1;
                 $company_reference = Setting::first();
                 $company_reference->update_attributes(array('company_reference' => $new_company_reference));
                 if (!$company) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_company_add_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_company_add_success'));
                 }
                 redirect('clients/view/' . $companyid->id);
             } else {
                 $this->view_data['clients'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
                 $this->view_data['next_reference'] = Company::last();
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_add_new_company');
                 $this->view_data['form_action'] = 'clients/company/create';
                 $this->content_view = 'clients/_company';
             }
             break;
         case 'update':
             if ($_POST) {
                 unset($_POST['send']);
                 $id = $_POST['id'];
                 if (isset($_POST['view'])) {
                     $view = $_POST['view'];
                     unset($_POST['view']);
                 }
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $company = Company::find($id);
                 $company->update_attributes($_POST);
                 if (!$company) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_company_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_company_success'));
                 }
                 redirect('clients/view/' . $id);
             } else {
                 $this->view_data['company'] = Company::find($id);
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_edit_company');
                 $this->view_data['form_action'] = 'clients/company/update';
                 $this->content_view = 'clients/_company';
             }
             break;
         case 'delete':
             $company = Company::find($id);
             $company->inactive = '1';
             $company->save();
             foreach ($company->clients as $value) {
                 $client = Client::find($value->id);
                 $client->inactive = '1';
                 $client->save();
             }
             $this->content_view = 'clients/all';
             if (!$company) {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_delete_company_error'));
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_delete_company_success'));
             }
             redirect('clients');
             break;
     }
 }
 public function Get_record_file_handle()
 {
     //<--this function helps to find and return clculating records data
     $csvStored_data = "";
     $start_date = $this->get_date_period_start();
     $end_date = $this->get_date_period_ends();
     $month_start = $start_date[1] - 1;
     //<--special arrangement for yahoo finance data (0 -> january)
     $month_ends = $end_date[1] - 1;
     //<--special arrangement for yahoo finance data (0 -> january)
     $file = 'http://ichart.yahoo.com/table.csv?s=' . $this->company_symbol . '&a=' . $month_start . '&b=' . $start_date[2] . '&c=' . $start_date[0] . '&d=' . $month_ends . '&e=' . $end_date[2] . '&f=' . $end_date[0] . '&g=' . $this->interval . '&ignore=.csv';
     $stored_data = CompanyData::get_last_updated_record($this->company_symbol);
     //<-- this function finds the data from database
     if ($stored_data) {
         if (date("Y-m-d", strtotime($stored_data->updated)) < date("Y-m-d", time()) || $stored_data->accuracy < $this->precision) {
             $csvStored_data = csv_to_array($file, ',');
             //<----exploring CSV file
             if (count($csvStored_data) > 4) {
                 //<--checks for the genuinity
                 $company_id = Company::find_company_id_company_symbol($this->company_symbol);
                 $prediction = CompanyData::where('comp_id_fk', '=', $company_id)->delete();
                 $company = CompanyData::create(array('comp_id_fk' => $company_id, 'csvdata' => serialize($csvStored_data), 'updated' => date("Y-m-d H:i:s", time()), 'accuracy' => $this->precision));
             }
         } else {
             $csvStored_data = unserialize($stored_data->csvdata);
         }
         $this->company_description = $stored_data->description;
         $this->company_address = $stored_data->address;
     } else {
         $company = new Company();
         $company->company_name = trim($this->company_name);
         $this->company_description = get_Company_data($this->company_symbol, 'desci');
         get_Company_logo($this->company_symbol);
         //<--fuction used to copy image
         $company->description = $this->company_description;
         $company->company_symbol = trim($this->company_symbol);
         $csvStored_data = csv_to_array($file, ',');
         //<----exploring CSV file
         if (count($csvStored_data) > 4) {
             //<--checks for the genuinity
             $company = Company::create(array('company_name' => trim($this->company_name), 'company_description' => get_Company_data($this->company_symbol, 'desci'), 'description' => $this->company_description, 'company_symbol' => trim($this->company_symbol)));
             if ($company) {
                 if ($csvStored_data) {
                     get_Company_logo($this->company_symbol);
                     //<--fuction used to copy image
                 }
                 $CompanyData = CompanyData::create(array('comp_id_fk' => trim($company->id), 'csvdata' => serialize($csvStored_data), 'updated' => date("Y-m-d H:i:s", time()), 'accuracy' => $this->precision));
                 $predict_data = Prediction::create(array('comp_id_fk' => trim($company->id)));
             }
         }
     }
     return !empty($csvStored_data) ? $csvStored_data : false;
 }
 function create_client($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $client = Company::create($_POST);
         $new_client_reference = $_POST['reference'] + 1;
         $client_reference = Setting::first();
         $client_reference->update_attributes(array('company_reference' => $new_client_reference));
         if (!$client) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_company_add_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_company_add_success'));
         }
         redirect('clients');
     } else {
         $this->view_data['client'] = Quote::find($id);
         $next_reference = Company::last();
         $reference = $next_reference->reference + 1;
         $this->view_data['client_reference'] = $reference;
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_add_new_company');
         $this->view_data['form_action'] = 'quotations/create_client';
         $this->content_view = 'quotations/_clients';
     }
 }
Example #14
0
     return View::create('companies/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/companies/add', function () {
     $input = Input::get(array('title', 'slug', 'description'));
     $validator = new validator($input);
     $validator->check('title')->is_max(3, __('companies.title_missing'));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/companies/add');
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     $company = Company::create($input);
     Extend::process('company', $company->id);
     Notify::success(__('companies.created'));
     return Response::redirect('admin/companies');
 });
 Route::get('admin/companies/delete/(:num)', function ($id) {
     $total = Company::count();
     if ($total == 1) {
         Notify::error(__('companies.delete_error'));
         return Response::redirect('admin/companies/edit/' . $id);
     }
     $company = Company::where('id', '<>', $id)->fetch();
     Company::find($id)->delete();
     Post::where('company', '=', $id)->update(array('company' => $company->id));
     Notify::success(__('companies.deleted'));
     return Response::redirect('admin/companies');
Example #15
0
 protected static function createTestCompany()
 {
     self::setTestApiKey();
     self::randomizeCompanyName();
     return Company::create(self::$test_company);
 }
Example #16
0
 public function store()
 {
     return Company::create(Input::only('rut', 'fancy_name'));
 }
Example #17
0
 public function createCompany()
 {
     $c = Company::create(["name" => "testC" . rand(0, 10000)]);
     return $c;
 }
Example #18
0
 public function addCompany($data)
 {
     $company = new Company($this->getUser()->id);
     $result = $company->create($data);
     return $result;
 }
 public function createModels()
 {
     $models = [];
     $models["c1"] = Company::create(["name" => "test 1"]);
     $models["c2"] = Company::create(["name" => "test 2"]);
     $models["a"] = User::create(["name" => "admin", "email" => "*****@*****.**", "company_id" => $models["c1"]->id, "type" => User::TYPE_ADMIN]);
     $models["p1"] = User::create(["name" => "user1", "email" => "*****@*****.**", "company_id" => $models["c1"]->id, "type" => User::TYPE_PAYEE, "code" => "1111"]);
     $models["p2"] = User::create(["name" => "user2", "email" => "*****@*****.**", "company_id" => $models["c1"]->id, "type" => User::TYPE_PAYEE, "code" => "2222"]);
     $models["p3"] = User::create(["name" => "user3", "email" => "*****@*****.**", "company_id" => $models["c1"]->id, "type" => User::TYPE_PAYEE, "code" => "3333"]);
     $models["p4"] = User::create(["name" => "user4", "email" => "*****@*****.**", "company_id" => $models["c2"]->id, "type" => User::TYPE_PAYEE, "code" => "4444"]);
     $models["p5"] = User::create(["name" => "user5", "email" => "*****@*****.**", "company_id" => $models["c2"]->id, "type" => User::TYPE_PAYEE, "code" => "5555"]);
     $models["p6"] = User::create(["name" => "user6", "email" => "*****@*****.**", "company_id" => $models["c2"]->id, "type" => User::TYPE_PAYEE, "code" => "6666"]);
     $models["p7"] = User::create(["name" => "user7", "email" => "*****@*****.**", "company_id" => $models["c2"]->id, "type" => User::TYPE_PAYEE, "code" => "7777"]);
     $models["pp1"] = PayeePayment::create(["amount" => 100, "status" => "unpaid", "payee_code" => $models["p1"]->code, "company_id" => $models["p1"]->company_id]);
     $models["pp2"] = PayeePayment::create(["amount" => 100, "status" => "paid", "payee_code" => $models["p1"]->code, "company_id" => $models["p1"]->company_id]);
     $models["pp3"] = PayeePayment::create(["amount" => 100, "status" => "unpaid", "payee_code" => $models["p1"]->code, "company_id" => $models["p1"]->company_id]);
     $models["pp4"] = PayeePayment::create(["amount" => 100, "status" => "paid", "payee_code" => $models["p2"]->code, "company_id" => $models["p2"]->company_id]);
     $models["pp5"] = PayeePayment::create(["amount" => 100, "status" => "paid", "payee_code" => $models["p2"]->code, "company_id" => $models["p2"]->company_id]);
     $models["pp6"] = PayeePayment::create(["amount" => 100, "status" => "unpaid", "payee_code" => $models["p2"]->code, "company_id" => $models["p2"]->company_id]);
     $models["pp7"] = PayeePayment::create(["amount" => 100, "status" => "unpaid", "payee_code" => $models["p2"]->code, "company_id" => $models["p2"]->company_id]);
     return $models;
 }
Example #20
0
<?php

include_once "../../../../../../libraries/aces/models/companypage.php";
// echo json_encode('xxx');
$_POST['userid'] = $_POST['userid'];
$_POST['company_name'] = $_POST['company_name'];
$_POST['email'] = $_POST['email'];
$_POST['about'] = $_POST['about'];
$_POST['website'] = $_POST['website'];
$_POST['specialties'] = $_POST['specialties'];
$_POST['industry'] = $_POST['industry'];
$_POST['locations'] = $_POST['locations'];
$_POST['size'] = $_POST['size'];
$_POST['type'] = $_POST['type'];
$_POST['status'] = $_POST['status'];
$cmp = new Company($user->id);
$data = $cmp->create($_POST);
// echo json_encode($data);
// print_r($data);
// foreach($data as $edudata){
// echo json_encode($edudata);
// }
Example #21
0
 function index()
 {
     $core_settings = Setting::first();
     if ($core_settings->registration != 1) {
         redirect('login');
     }
     if ($_POST) {
         $this->load->library('parser');
         $this->load->helper('file');
         $this->load->helper('notification');
         $client = Client::find_by_email($_POST['email']);
         if ($client->inactive == 1) {
             $client = FALSE;
         }
         $check_company = Company::find_by_name($_POST['name']);
         if (!$client && !$check_company && $_POST['name'] != "" && $_POST['email'] != "" && $_POST['password'] != "" && $_POST['firstname'] != "" && $_POST['lastname'] != "" && $_POST['confirmcaptcha'] != "") {
             $client_attr = array();
             $company_attr['name'] = $_POST['name'];
             $company_attr['website'] = $_POST['website'];
             $company_attr['phone'] = $_POST['phone'];
             $company_attr['mobile'] = $_POST['mobile'];
             $company_attr['address'] = $_POST['address'];
             $company_attr['zipcode'] = $_POST['zipcode'];
             $company_attr['city'] = $_POST['city'];
             $company_attr['country'] = $_POST['country'];
             $company_attr['province'] = $_POST['province'];
             $company_attr['vat'] = $_POST['vat'];
             $company_attr['reference'] = $core_settings->company_reference;
             $core_settings->company_reference = $core_settings->company_reference + 1;
             $core_settings->save();
             $company = Company::create($company_attr);
             if (!$company) {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
                 redirect('register');
             }
             $lastclient = Client::last();
             $client_attr = array();
             $client_attr['email'] = $_POST['email'];
             $client_attr['firstname'] = $_POST['firstname'];
             $client_attr['lastname'] = $_POST['lastname'];
             $client_attr['phone'] = $_POST['phone'];
             $client_attr['mobile'] = $_POST['mobile'];
             $client_attr['address'] = $_POST['address'];
             $client_attr['zipcode'] = $_POST['zipcode'];
             $client_attr['city'] = $_POST['city'];
             $modules = Module::find('all', array('order' => 'sort asc', 'conditions' => array('type = ?', 'client')));
             $client_attr['access'] = "";
             foreach ($modules as $value) {
                 if ($value->name == "Projects" || $value->name == "Messages" || $value->name == "Tickets" || $value->name == "Invoices") {
                     $client_attr['access'] .= $value->id . ",";
                 }
             }
             $client_attr['company_id'] = $company->id;
             $client = Client::create($client_attr);
             if ($client) {
                 $client->password = $client->set_password($_POST['password']);
                 $client->save();
                 $company->client_id = $client->id;
                 $company->save();
                 $this->email->from($core_settings->email, $core_settings->company);
                 $this->email->to($client_attr['email']);
                 $this->email->subject($this->lang->line('application_your_account_has_been_created'));
                 $parse_data = array('link' => base_url() . 'login/', 'company' => $core_settings->company, 'company_reference' => $company->reference, 'logo' => '<img src="' . base_url() . '' . $core_settings->logo . '" alt="' . $core_settings->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $core_settings->invoice_logo . '" alt="' . $core_settings->company . '"/>');
                 $email = read_file('./application/views/' . $core_settings->template . '/templates/email_create_account.html');
                 $message = $this->parser->parse_string($email, $parse_data);
                 $this->email->message($message);
                 $this->email->send();
                 send_notification($core_settings->email, $this->lang->line('application_new_client_has_registered'), $this->lang->line('application_new_client_has_registered') . ': <br><strong>' . $company_attr['name'] . '</strong><br>' . $client_attr['firstname'] . ' ' . $client_attr['lastname'] . '<br>' . $client_attr['email']);
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_success'));
                 redirect('login');
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
                 redirect('login');
             }
         } else {
             $this->view_data['error'] = $this->lang->line('messages_email_already_taken');
             $this->theme_view = 'login';
             $this->content_view = 'auth/register';
             $this->view_data['form_action'] = 'register';
             $this->view_data['registerdata'] = $_POST;
         }
     } else {
         $this->view_data['error'] = 'false';
         $this->theme_view = 'login';
         $this->content_view = 'auth/register';
         $this->view_data['form_action'] = 'register';
     }
 }
Example #22
0
 /**
  * Account sign up form processing.
  *
  * @return Redirect
  */
 public function postSignup()
 {
     $input = Input::all();
     // unset($input['company']);
     // return var_dump($input);
     // Declare the rules for the form validation
     $rules = array('first_name' => 'required|min:1', 'last_name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|between:3,32', 'password_confirm' => 'required|same:password');
     // Create a new validator instance from our validation rules
     $validator = Validator::make($input, $rules);
     // If validation fails, we'll exit the operation now.
     if ($validator->fails()) {
         // Ooops.. something went wrong
         if (isset($input['status'])) {
             //its from the popup
             // return Redirect::to('auth/signup')->withInput()->withErrors($validator);
             return Response::json(array('errors' => json_decode($validator->messages())));
         } else {
             return Redirect::back()->withInput()->withErrors($validator);
         }
     }
     try {
         // Register the user
         $user = Sentry::register(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'password' => Input::get('password')));
         //create company record if name has been given.
         if (!empty($input['company'])) {
             Company::create(array('name' => $input['company'], 'image' => 'no_logo.png', 'banner' => 'banner' . rand(1, 4) . '.png', 'creator' => $user->id));
         }
         // Data to be used on the email view
         $data = array('user' => $user, 'activationUrl' => URL::route('activate', $user->getActivationCode()));
         // Send the activation code through email
         Mail::send('emails.register-activate', $data, function ($m) use($user) {
             $m->to($user->email, $user->first_name . ' ' . $user->last_name);
             $m->subject('Welcome ' . $user->first_name);
         });
         // Redirect to the register page
         if (isset($input['status'])) {
             //its from the popup
             return Response::json(array('success' => Lang::get('auth/message.signup.success')));
             // return Redirect::back()->with('success', Lang::get('auth/message.signup.success'));
         } else {
             // return Redirect::back()->with('success', Lang::get('auth/message.signup.success'));
             return Redirect::to('success');
         }
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         $this->messageBag->add('email', Lang::get('auth/message.account_already_exists'));
     }
     // Ooops.. something went wrong
     if (isset($input['status'])) {
         //its from the popup
         // return Redirect::to('auth/signup')->with('success', Lang::get('auth/message.signup.success'));
         return Response::json(array('errors' => $this->messageBag));
     } else {
         return Redirect::to('auth/signup')->withInput()->withErrors($this->messageBag);
     }
 }