public function actionFunctionalities($id = 3)
 {
     $project = Project::findOne($id);
     $monthly = Functionality::find()->where("price > 1 AND project_id = " . $id . " AND monthly_costs = 1")->all();
     //All(['project_id' => $id, 'monthly_costs' => 1],['price','>',1]);
     $once = Functionality::find()->where("price > 1 AND project_id = " . $id . " AND monthly_costs = 0")->all();
     //(['project_id' => $id, 'monthly_costs' => 0],['price','>',1]);
     $solidCostsMonthly = new Functionality();
     $solidCostsMonthly->name = "Vaste Maandelijkse Kosten";
     $solidCostsMonthly->price = 39.95;
     array_push($monthly, $solidCostsMonthly);
     $solidCostOnce = new Functionality();
     $solidCostOnce->name = "Vaste maandelijkse kosten";
     $solidCostOnce->price = 250;
     array_push($once, $solidCostOnce);
     //            var_dump($monthly); exit;
     $oneOffDataProvider = new ArrayDataProvider(['allModels' => $once]);
     $monthlyDataProvider = new ArrayDataProvider(['allModels' => $monthly]);
     $this->layout = '@common/mail/layouts/html';
     $totalMonthly = 0;
     foreach ($monthlyDataProvider->allModels as $model) {
         $totalMonthly += $model->price;
     }
     $totalOnce = 0;
     foreach ($oneOffDataProvider->allModels as $model) {
         $totalOnce += $model->price;
     }
     return $this->render('@common/mail/overviewMail-html', ['oneOffDataProvider' => $oneOffDataProvider, 'monthlyDataProvider' => $monthlyDataProvider, 'totalMonthly' => $totalMonthly, 'totalOnce' => $totalOnce]);
 }
 /**
  * Finds the Project model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Project the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Project::findProjectOne($id)) != null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Deletes an existing ProjectCategorySecond model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $projectModel = Project::find()->andWhere(['category_id' => $id])->one();
     if (null === $projectModel) {
         $this->findModel($id)->delete();
     } else {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for project #' . $projectModel->id . ' before delete.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
 /**
  * Creates a new Functionality model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Functionality();
     $projects = Project::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->functionality_id]);
     } else {
         return $this->render('create', ['model' => $model, 'projects' => $projects]);
     }
 }
Example #5
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Project::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
Example #6
0
 public function actionUpdate($id = 0)
 {
     //      $out = ['status' => 'err', 'error' => 'Unknown error'];
     if (\Yii::$app->user->isGuest) {
         throw new NotFoundHttpException();
     }
     $r = new Request();
     if (isset($r->post('Project')['id']) && $r->post('Project')['id']) {
         $id = $r->post('Project')['id'];
     }
     //      vd($r->post('Company'));
     $userID = \Yii::$app->user->getId();
     if ($id) {
         $project = Project::findOne(['id' => $id, 'user_id' => $userID]);
     } else {
         $project = new Project();
         //        \Yii::$app->session->setFlash('error', 'Company ID is required.');
         //        $this->redirect(array('view','id'=>$company));
         //        $this->redirect(array('index'));
         //        return;
     }
     //        vd($company);
     if ($project) {
         if ($project->load($r->post())) {
             $project->user_id = $userID;
             if ($project->validate() && $project->save()) {
                 //vd([$r->post(),$order->attributes]);
                 //          $out = [
                 //            'status' => 'ok',
                 //            'order' => $order->id,
                 //            'user' => $order->user_id,
                 //            'sum' => $order->price / 100,
                 //          ];
                 //          $this->redirect(array('view','id'=>$company));
             } else {
                 //          vd($company->errors);
                 \Yii::$app->session->setFlash('error', array_values($project->errors)[0][0]);
                 //          $out['error'] = array_values($order->errors)[0][0];
                 //vd($order->errors);
             }
         }
     } else {
         \Yii::$app->session->setFlash('error', 'Такой проект не существует');
         $this->redirect(array('my'));
         return;
     }
     return $this->render('update', ['project' => $project]);
     //      \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     //      return $out;
     /*vd(['get' => $r->getQueryParams() ,
       'post' => $r->post(),
       'order' => $order],1); //*/
 }
Example #7
0
 public function actionIndex($name = null)
 {
     if (is_null($name)) {
         $project = Project::find()->select('domain')->asArray()->all();
         foreach ($project as $item) {
             if (strpos($item['domain'], 'backend.') === false) {
                 $this->getDomain($item['domain']);
             }
         }
     } else {
         $this->getDomain($name);
     }
 }
Example #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Project::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(['pr_id' => $this->pr_id]);
     $query->andFilterWhere(['like', 'pr_name', $this->pr_name]);
     return $dataProvider;
 }
Example #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Project::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(['id' => $this->id, 'created' => $this->created, 'updated' => $this->updated, 'owner' => $this->owner]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'announce', $this->announce])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Example #10
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Project::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]);
     return $dataProvider;
 }
Example #11
0
 public function init()
 {
     $domain = Yii::$app->params['domain'];
     $domain = str_replace('www.', '', $domain);
     $project = Project::find()->where(['domain' => $domain])->with(['theme', 'language'])->with(['groups' => function ($query) {
         /** @var $query \yii\db\ActiveQuery */
         $query->with(['patterns' => function ($query) {
             /** @var $query \yii\db\ActiveQuery */
             $query->with(['type', 'translations'])->orderBy(['priority' => SORT_ASC]);
         }]);
     }])->asArray()->one();
     if (!$project) {
         throw new HttpException(503, 'no domain');
     }
     $result = [];
     foreach ($project['groups'] as $value) {
         foreach ($value['patterns'] as $pattern) {
             if (!empty($pattern['translations']) && @$pattern['translations'][0]['language_id'] == $project['language_id']) {
                 $result[$pattern['type']['alias']][$pattern['module']][] = $pattern['translations'][0]['value'];
             } else {
                 $result[$pattern['type']['alias']][$pattern['module']][] = $pattern['value'];
             }
         }
     }
     unset($project['groups']);
     $project['patterns'] = $result;
     Yii::$app->name = $project['name'];
     Yii::$app->language = $project['language']['code'];
     // проверяем существовании папки с темой .. добавляем в список и делаем её активной
     if (file_exists(Yii::getAlias("@themes/" . $project['theme']['name']))) {
         Yii::$app->view->theme->basePath = "@themes/" . $project['theme']['name'];
         Yii::$app->view->theme->active = $project['theme']['name'];
         array_unshift(Yii::$app->view->theme->pathMap['@app/views'], "@themes/" . $project['theme']['name']);
         array_unshift(Yii::$app->view->theme->pathMap['@app/modules'], '@themes/' . $project['theme']['name'] . '/modules');
         array_unshift(Yii::$app->view->theme->pathMap['@app/widgets'], '@themes/' . $project['theme']['name'] . '/widgets');
     }
     self::$info = $project;
 }
Example #12
0
<div class="project-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

	<div class="block">
	    <?php 
if ($dataProvider2) {
    if ($dataProvider2->getTotalCount() !== 0) {
        echo '<h2>Nieuwe projectaanvragen</h2>';
        echo GridView::widget(['dataProvider' => $dataProvider2, 'filterModel' => $searchModel2, 'columns' => ['description', ['attribute' => 'client_id', 'value' => 'client.name'], ['attribute' => 'projectmanager_id', 'value' => 'projectmanager.username'], ['attribute' => 'status', 'value' => 'statusName', 'filter' => Html::activeDropDownList($searchModel2, 'status', Project::statusses(), ['prompt' => 'Alles', 'class' => 'form-control'])], ['class' => 'yii\\grid\\ActionColumn']]]);
    }
}
?>
	
		<h2>Projecten</h2>
		
		<p>
	        <?php 
echo \Yii::$app->user->can('createProject') ? Html::a(Yii::t('project', 'Create Project'), ['create'], ['class' => 'btn btn-success']) : Html::a(Yii::t('project', 'Request Project'), ['/request-project'], ['class' => 'btn btn-success']);
?>
	    </p>
	    
	    <?php 
echo GridView::widget(['dataProvider' => $dataProvider1, 'filterModel' => $searchModel1, 'columns' => ['description', ['attribute' => 'client_id', 'value' => 'client.name'], ['attribute' => 'projectmanager_id', 'value' => 'projectmanager.username'], ['attribute' => 'status', 'value' => 'statusName', 'filter' => Html::activeDropDownList($searchModel2, 'status', Project::statusses(), ['prompt' => 'Alles', 'class' => 'form-control'])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
	</div>
</div>
Example #13
0
 public function afterDelete()
 {
     Project::deleteAll(['locale_group_id' => $this->locale_group_id]);
     return parent::afterDelete();
 }
Example #14
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Page */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="page-form">

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

    <?php 
echo $form->field($model, 'project_id')->dropdownList(\common\models\Project::find()->select(['domain', 'id'])->indexBy('id')->column(), ['prompt' => 'Domain:'])->label('Domain');
?>

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

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

    <?php 
echo $form->field($model, 'content')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['replaceDivs' => false, 'lang' => 'ru', 'minHeight' => 200, 'plugins' => ['clips', 'fullscreen'], 'pastePlainText' => false, 'paragraphize' => false]]);
?>
    <?php 
echo $form->field($model, 'as_theme')->dropdownList([1 => 'yes', 0 => 'no']);
<?php

use yii\helpers\Html;
use common\models\Project;
/* @var $this yii\web\View */
/* @var $model common\models\Functionality */
$project = Project::findOne(['project_id' => $pid]);
$this->title = Yii::t('functionality', 'Create Functionality');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Projects'), 'url' => ['/project/index']];
$this->params['breadcrumbs'][] = ['label' => $project->description, 'url' => ['/project/view', 'id' => $project->project_id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="functionality-create">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['models' => $models]);
?>

</div>
 /**
  * Updates an existing File model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (!Yii::$app->user->can('editFile', ['file' => $model])) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->file_id]);
     } else {
         return $this->render('update', ['model' => $model, 'projects' => Project::find()->all(), 'todos' => Todo::find()->all()]);
     }
 }
Example #17
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProject()
 {
     return $this->hasOne(Project::className(), ['id' => 'project_id']);
 }
Example #18
0
 public static function getMetaTags()
 {
     $tags = [];
     $locale = null;
     preg_match('/^(.+)\\/(.+)\\/(.+)\\/(.+)/', Yii::$app->request->pathInfo, $matches);
     if (!empty($matches[1]) and !empty($matches[2]) and !empty($matches[3])) {
         $shortLocale = $matches[1];
         $controller = $matches[2];
         $action = $matches[3];
         $slug = $matches[4];
         foreach (Yii::$app->params['availableLocales'] as $k => $v) {
             if ($shortLocale == explode('-', $k)[0]) {
                 $locale = $k;
             }
         }
         switch ($controller) {
             case 'page':
                 $model = self::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
             case 'article':
                 $model = Article::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
             case 'project':
                 $model = Project::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
         }
         //hardcore :) json to array
         if (!empty($model) and !empty($model->head)) {
             $arr = json_decode($model->head, true);
             foreach ($arr as $key => $value) {
                 foreach ($value as $key2 => $value2) {
                     $tags[] = $value2;
                 }
             }
         }
         Yii::$app->view->title = $model->title;
     }
     return $tags;
 }
Example #19
0
 public static function getMetaTags()
 {
     $tags = [];
     $locale = null;
     $arr = self::parseUrl(Yii::$app->request->pathInfo);
     if (!empty($arr[0]) and !empty($arr[1]) and !empty($arr[2]) and !empty($arr[3])) {
         $shortLocale = $arr[0];
         $controller = $arr[1];
         $action = $arr[2];
         $slug = $arr[3];
         foreach (Yii::$app->params['availableLocales'] as $k => $v) {
             if ($shortLocale == explode('-', $k)[0]) {
                 $locale = $k;
             }
         }
         switch ($controller) {
             case 'page':
                 $model = self::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
             case 'article':
                 $model = Article::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
             case 'promo':
                 //$model = Promo::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
             case 'project':
                 $model = Project::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one();
                 break;
         }
         //hardcore :) json to array
         if (!empty($model) and !empty($model->head)) {
             $arr = json_decode($model->head, true);
             foreach ($arr as $key => $value) {
                 foreach ($value as $key2 => $value2) {
                     //custom meta tag
                     if (4 == count($value2)) {
                         $value2 = array_values($value2);
                         $value2 = [$value2[0] => $value2[1], $value2[2] => $value2[3]];
                     }
                     $tags[] = $value2;
                 }
             }
         }
         if (empty($model)) {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
         if (!empty($tags[0]) and !empty($tags[0]['name']) and 'title' == !empty($tags[0]['name']) and !empty($tags[0]['content'])) {
             Yii::$app->view->title = $tags[0]['content'];
         } else {
             Yii::$app->view->title = $model->title;
         }
     }
     return $tags;
 }
Example #20
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProjects2()
 {
     return $this->hasMany(Project::className(), ['updater_id' => 'id']);
 }
Example #21
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProjects()
 {
     return $this->hasMany(Project::className(), ['language_id' => 'id']);
 }
Example #22
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $project = Project::findOne(1);
     return $this->render('index', ['project' => $project, 'persons' => $project->getOrders()->where('closed_at IS NOT NULL')->select('user_id')->distinct()->count()]);
 }
Example #23
0
?>

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

    <?php 
echo $form->field($model, 'description')->textInput();
?>

    <?php 
echo $form->field($model, 'todo_id')->dropdownList(ArrayHelper::map(Todo::find()->all(), 'todo_id', 'name'));
?>

    <?php 
echo $form->field($model, 'project_id')->dropdownList(ArrayHelper::map(Project::find()->all(), 'project_id', 'description'));
?>

    <?php 
echo $form->field($model, 'deleted')->checkBox();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('common', 'Create') : Yii::t('common', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #24
0
 public function actionIndex($project)
 {
     $project_data = Project::findOne($project);
     //vd($order);
     return $this->render('index', ['project' => $project_data, 'order' => new Order(['project_id' => $project_data->id]), 'signup' => \Yii::$app->user->isGuest ? new SignupForm() : null]);
 }
Example #25
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProjects()
 {
     return $this->hasMany(Project::className(), ['category_id' => 'id']);
 }
 private function generateProject($uid)
 {
     // Get the Parts
     $steps = $this->getSessionPartsAsArray();
     // Create Project
     $project = new Project();
     $user;
     $customer;
     $previousUser = false;
     if (Yii::$app->session->has('customer')) {
         $customer = Yii::$app->session->get('customer');
         $user = $customer->user;
     } else {
         $user = User::find()->where(['id' => $uid])->one();
         $customer = Customer::find()->where(['user_id' => $user->id])->one();
     }
     // Log in the user temporarily so the project and functionalities get the right creator_id and updater_id
     if (Yii::$app->user->isGuest) {
         Yii::$app->user->login($user);
     } else {
         $previousUser = true;
     }
     $project->client_id = $customer->customer_id;
     $project->status = 0;
     $project->name = $customer->name;
     $project->deleted = 0;
     $project->description = 'Doel van de website: ' . $steps[1]->goal;
     $project->save(false);
     $location = $this->permFileLocation . $project->project_id . '/';
     if (!file_exists($location)) {
         mkdir($location);
     }
     $i = 1;
     $comments = Yii::t('request-project', ' Comments:');
     foreach ($steps as $step) {
         $comment = $this->saveFunctionalities($step, $project->project_id, $uid);
         if (!empty($comment)) {
             $comments .= ' ' . Yii::t('request-project', 'Step');
             $comments .= ' ' . $i . ': ';
             $comments .= $comment;
         }
         $i++;
     }
     if ($comments != Yii::t('request-project', ' Comments:')) {
         $project->description .= $comments;
         $project->save(false);
     }
     // Log the user out
     if (!$previousUser) {
         Yii::$app->user->logout();
     }
     // Notify the admin
     $mail = Yii::$app->mailer->compose(['html' => 'newProjectRegistered-html', 'text' => 'newProjectRegistered-text'], ['customer' => $customer, 'project' => $project]);
     $mail->setFrom('*****@*****.**');
     $mail->setTo('*****@*****.**');
     $mail->setSubject('Er is een nieuw project aangevraagd door ' . $customer->name);
     $mail->send();
     return $project;
 }
Example #27
0
 /**
  * 计算增配/减配操盘金范围
  * @return ['max_op' => $max_op, 'min_op' => $min_op]
  */
 public static function getIncreaseOpInterval($money_cur_insure, $power, $plan_type, $to_increase = true)
 {
     $project_info = Project::getInfo($plan_type);
     if ($to_increase == true) {
         $max_insure = $project_info['insure_max'] - $money_cur_insure;
     } else {
         $max_insure = $money_cur_insure - $project_info['insure_min'];
     }
     $min_insure = $project_info['insure_min'];
     if ($max_insure < $min_insure || $max_insure == 0) {
         return false;
     }
     return ["max_insure" => $max_insure, "min_insure" => $min_insure];
 }
Example #28
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-create">
	<div class="block">
    
    <?php 
$form = ActiveForm::begin();
$projectmanagers = User::getProjectManagers();
$customers = Customer::find()->all();
?>

    <?php 
echo $form->field($model, 'description')->textInput();
?>
    <?php 
echo $form->field($model, 'status')->dropDownList(Project::statusses());
?>
    <?php 
echo $form->field($model, 'projectmanager_id')->dropDownList(ArrayHelper::map($projectmanagers, 'id', 'username'), ['prompt' => Yii::t('project', 'Select a projectmanager')]);
?>
	    
    <div id="existing-user" style="display:none;">
    	<fieldset>
    		<legend><?php 
echo Yii::t('project', 'Existing user');
?>
</legend>
	    		<?php 
echo Html::button(Yii::t('user', 'New User'), ['onClick' => 'js:newContact()', 'class' => 'btn btn-default']);
?>