public function store($companyId, $request)
 {
     $cacheTag = ['companies', 'company' . $companyId, 'domains'];
     $cacheKey = 'index';
     $_companies = Companies::find($companyId);
     if ($_companies) {
         if (!empty($request['domains'])) {
             foreach ($request['domains'] as $value) {
                 if (strpos($value, 'localhost') !== 0) {
                     $validator = $this->validate($value);
                     if ($validator->fails()) {
                         return new \Exception($validator->errors()->first());
                     }
                 }
                 if (Domains::where('domain', '=', $value)->where('company_id', '<>', $companyId)->count() > 0) {
                     return new \Exception('O domínio ' . $value . ' já está sendo usado por outro company');
                 }
             }
             $_companies->domains()->delete();
             foreach ($request['domains'] as $value) {
                 Logs::create(['activity' => 'store', 'module' => 'companies_domains', 'ref' => $value]);
                 $_companies->domains()->create(['company_id' => $companyId, 'domain' => $value]);
             }
             Cache::tags($cacheTag)->flush();
             return true;
         } else {
             return true;
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
示例#2
0
 public function searchsubd($params)
 {
     $query = Companies::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     // load the search form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Companies::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['company_id' => $this->company_id, 'company_created_date' => $this->company_created_date, 'company_inception' => $this->company_inception]);
     $query->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'company_email', $this->company_email])->andFilterWhere(['like', 'company_address', $this->company_address])->andFilterWhere(['like', 'company_status', $this->company_status]);
     return $dataProvider;
 }
 public function destroy($companyId, $managerId)
 {
     $cacheTag = ['companies', 'company' . $companyId, 'managers'];
     $_company = Companies::find($companyId);
     if ($_company) {
         $_manager = $_company->managers()->select(['id'])->where('id', '=', $managerId);
         if ($_manager->count() > 0) {
             Cache::tags($cacheTag)->flush();
             Logs::create(['activity' => 'destroy', 'module' => 'companies_managers', 'ref' => $managerId]);
             return $_company->managers()->detach($_manager->first()->id);
         } else {
             return new \Exception("Houve um erro ao localizar registro (manager not found)");
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
 /**
  * Search companies based on current criteria
  */
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "App\\Models\\Companies", $this->request->getPost());
         $this->persistent->searchParams = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
     }
     $parameters = array();
     if ($this->persistent->searchParams) {
         $parameters = $this->persistent->searchParams;
     }
     $companies = Companies::find($parameters);
     if (count($companies) == 0) {
         $this->flash->notice("The search did not find any companies");
         return $this->forward("companies/index");
     }
     $paginator = new Paginator(array("data" => $companies, "limit" => 10, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
     $this->view->companies = $companies;
 }
示例#6
0
use yii\helpers\ArrayHelper;
use app\models\Companies;
use app\models\Branches;
/* @var $this yii\web\View */
/* @var $model app\models\Departments */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="departments-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'companies_company_id')->dropDownList(ArrayHelper::map(Companies::find()->all(), 'company_id', 'company_name'), ['prompt' => 'Select a company..']);
?>

    <?php 
echo $form->field($model, 'branches_branch_id')->dropDownList(ArrayHelper::map(Branches::find()->all(), 'branch_id', 'branch_name'), ['prompt' => 'Select a branch..']);
?>

    <?php 
echo $form->field($model, 'department_name')->textInput(['maxlength' => true]);
?>

    

    <?php 
echo $form->field($model, 'department_status')->dropDownList(['active' => 'Active', 'inactive' => 'Inactive', '' => ''], ['prompt' => '']);
?>
示例#7
0
 public static function getConfigutationsByCompanyId($companyId)
 {
     $_company = Companies::find($companyId);
     return $_company->configurations;
 }
 public function destroy($id)
 {
     $cacheTag = ['companies'];
     if ($this->isManager($id)) {
         $_model = Companies::find($id);
         if ($_model) {
             Logs::create(['activity' => 'destroy', 'module' => 'companies', 'ref' => $id]);
             Cache::tags($cacheTag)->flush();
             return $_model->delete();
         } else {
             return new \Exception("Houve um erro ao localizar registro (id not found)");
         }
     } else {
         return new \Exception('Você não tem permissão para realizar esta ação >:(');
     }
 }
示例#9
0
 public function getkycCompanyinfo()
 {
     $email = strtolower($this->request->query['email']);
     $kycid = $this->request->query['kycid'];
     if ($email == "" || $kycid == "") {
         return $this->render(array('json' => array('success' => 0)));
     }
     $document = Companies::find('first', array('conditions' => array('email' => $email, 'email_code' => $kycid)));
     $encrypt = $document['hash'];
     //		print_r($function->decrypt($encrypt,CONNECTION_DB_KYC));
     if (count($document) == 1) {
         if ($emails['Verify']['Score'] >= 80) {
             return $this->render(array('json' => array('success' => 0, 'reason' => 'Aleredy KYC complete')));
         } else {
             return $this->render(array('json' => array('success' => 1, 'id' => $encrypt)));
         }
     } else {
         return $this->render(array('json' => array('success' => 0)));
     }
 }
示例#10
0
use app\models\Companies;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model app\models\Branches */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="branches-form">

    <?php 
$form = ActiveForm::begin();
?>

  
    <?php 
echo $form->field($model, 'companies_company_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Companies::find()->all(), 'company_id', 'company_name'), 'language' => 'en', 'options' => ['placeholder' => 'Select a company ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
		

    <?php 
echo $form->field($model, 'branch_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'branch_address')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'branch_status')->dropDownList(['active' => 'Active', 'inactive' => 'Inactive', '' => ''], ['prompt' => '']);
?>
示例#11
0
 public function verifyCompany($id = null)
 {
     $company = Companies::find('first', array('conditions' => array('hash' => $id)));
     if (count($company) == 0) {
         return $this->redirect('kyc::index');
         exit;
     }
     if ($company['verify']['verified'] == "Yes") {
         return $this->redirect('kyc::verified');
     }
     $image_corporation = File::find('first', array('conditions' => array('details_corporation_id' => (string) $company['_id'])));
     if ($image_corporation['filename'] != "") {
         $imagename_corporation = $image_corporation['_id'] . '_' . $image_corporation['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_corporation;
         file_put_contents($path, $image_corporation->file->getBytes());
     }
     $image_articles = File::find('first', array('conditions' => array('details_articles_id' => (string) $company['_id'])));
     if ($image_articles['filename'] != "") {
         $imagename_articles = $image_articles['_id'] . '_' . $image_articles['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_articles;
         file_put_contents($path, $image_articles->file->getBytes());
     }
     $image_resolution = File::find('first', array('conditions' => array('details_resolution_id' => (string) $company['_id'])));
     if ($image_resolution['filename'] != "") {
         $imagename_resolution = $image_resolution['_id'] . '_' . $image_resolution['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_resolution;
         file_put_contents($path, $image_resolution->file->getBytes());
     }
     $image_directors = File::find('first', array('conditions' => array('details_directors_id' => (string) $company['_id'])));
     if ($image_directors['filename'] != "") {
         $imagename_directors = $image_directors['_id'] . '_' . $image_directors['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_directors;
         file_put_contents($path, $image_directors->file->getBytes());
     }
     return compact('company', 'imagename_corporation', 'imagename_articles', 'imagename_resolution', 'imagename_directors');
 }