Exemplo n.º 1
0
 /**
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $cloneModel = $this->clone->find($event->request['clone_id']);
     $group = $this->group->find($event->request['group_id']);
     $sitePath = Str::camel($event->request['name']);
     $event->site->updateStatus('Cloning the repo');
     $this->envoy->run('clone --path="' . $group->starting_path . '" --name="' . $sitePath . '" --url=' . $cloneModel->url, true);
 }
Exemplo n.º 2
0
 /**
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $event->site->updateStatus('Running the installer');
     $installerType = $event->request['installType'] == 'base' ? null : '"--' . $event->request['installType'] . '"';
     $group = $this->group->find($event->request['group_id']);
     $sitePath = Str::camel($event->request['name']);
     $this->envoy->run('make-site --path="' . $group->starting_path . '" --name="' . $sitePath . '" --type=' . $installerType, true);
 }
Exemplo n.º 3
0
 /**
  * 提交任务
  *
  * @param $projectId 没有projectId则显示列表
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     // 为了方便用户更改表名,避免表名直接定死
     $projectTable = Project::tableName();
     $groupTable = Group::tableName();
     if (!$projectId) {
         // 显示所有项目列表
         $projects = Project::find()->leftJoin(Group::tableName(), "`{$groupTable}`.`project_id` = `{$projectTable}`.`id`")->where(["`{$projectTable}`.status" => Project::STATUS_VALID, "`{$groupTable}`.`user_id`" => $this->uid])->asArray()->all();
         return $this->render('select-project', ['projects' => $projects]);
     }
     $task = new Task();
     $conf = Project::getConf($projectId);
     if (!$conf) {
         throw new \Exception(yii::t('task', 'unknown project'));
     }
     if (\Yii::$app->request->getIsPost()) {
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 return $this->redirect('@web/task/');
             }
         }
     }
     $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
     return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
 }
Exemplo n.º 4
0
 /**
  * 提交任务
  *
  * @param $projectId
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     $task = new Task();
     if ($projectId) {
         $conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
     }
     if (\Yii::$app->request->getIsPost()) {
         if (!$conf) {
             throw new \Exception(yii::t('task', 'unknown project'));
         }
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 return $this->redirect('/task/');
             }
         }
     }
     if ($projectId) {
         $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
         return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
     }
     // 成员所属项目
     $projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
     return $this->render('select-project', ['projects' => $projects]);
 }
Exemplo n.º 5
0
 public function run()
 {
     $total = [];
     foreach (Group::find()->all() as $key => $group) {
         $total[$group->name] = GroupClient::find()->where(['groups_id' => $group->id])->count();
     }
     return $this->render('groups/index', ['group' => new Group(), 'total' => $total]);
 }
Exemplo n.º 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['p_id' => $this->p_id]);
     $query->andFilterWhere(['like', 'bezeichnung', $this->bezeichnung]);
     return $dataProvider;
 }
Exemplo n.º 7
0
 /**
  * 项目添加用户
  *
  * @param $projectId
  * @param $userId
  * @return bool
  */
 public static function addGroupUser($projectId, $userId)
 {
     // 是否已在组内
     $exists = Group::find()->where(['project_id' => $projectId, 'user_id' => $userId])->count();
     if ($exists) {
         return true;
     }
     $group = new Group();
     $group->attributes = ['project_id' => $projectId, 'user_id' => $userId];
     return $group->save();
 }
Exemplo n.º 8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Exemplo n.º 9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $pageSize = Yii::$app->session->get('pageSize', Yii::$app->params['defaultPageSize']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['p_id' => $this->p_id]);
     $query->andFilterWhere(['like', 'bezeichnung', $this->bezeichnung]);
     return $dataProvider;
 }
Exemplo n.º 10
0
 public function groups()
 {
     $groups = Group::find('all', array('conditions' => array('y2011' => array('$gte' => 0)), 'order' => array('name' => 'asc'), 'limit' => 9))->to('array');
     $total = 0;
     foreach ($groups as $group) {
         $total += $group['y2011'];
     }
     foreach ($groups as &$group) {
         $group['percentage'] = round($group['y2011'] / $total, 4);
     }
     return compact('total', 'groups');
 }
Exemplo n.º 11
0
 /**
  * 配置项目
  *
  * @param $projectId
  * @return string
  * @throws \Exception
  */
 public function actionGroup($projectId)
 {
     // 配置信息
     $project = $this->findModel($projectId);
     // 添加用户
     if (\Yii::$app->request->getIsPost() && \Yii::$app->request->post('user')) {
         Group::addGroupUser($projectId, \Yii::$app->request->post('user'));
     }
     // 项目的分组用户
     $group = Group::find()->with('user')->where(['project_id' => $projectId])->indexBy('user_id')->orderBy(['type' => SORT_DESC])->asArray()->all();
     // 所有用户
     $users = User::find()->select(['id', 'email', 'realname'])->where(['is_email_verified' => 1])->asArray()->all();
     return $this->render('group', ['conf' => $project, 'users' => $users, 'group' => $group]);
 }
Exemplo n.º 12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'nama', $this->nama]);
     return $dataProvider;
 }
Exemplo n.º 13
0
 /**
  * 项目添加用户
  *
  * @param $projectId
  * @param $userId array
  * @return bool
  */
 public static function addGroupUser($projectId, $userIds, $type = Group::TYPE_USER)
 {
     // 是否已在组内
     $exitsUids = Group::find()->select(['user_id'])->where(['project_id' => $projectId, 'user_id' => $userIds])->column();
     $notExists = array_diff($userIds, $exitsUids);
     if (empty($notExists)) {
         return true;
     }
     $group = new Group();
     foreach ($notExists as $uid) {
         $relation = clone $group;
         $relation->attributes = ['project_id' => $projectId, 'user_id' => $uid, 'type' => $type];
         $relation->save();
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * 提交任务
  *
  * @param $projectId
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     $task = new Task();
     if ($projectId) {
         // svn下无trunk
         $nonTrunk = false;
         $conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
         $conf = Project::getConf($projectId);
         // 第一次可能会因为更新而耗时,但一般不会,第一次初始化会是在检测里
         if ($conf->repo_type == Project::REPO_SVN && !file_exists(Project::getDeployFromDir())) {
             $version = Repo::getRevision($conf);
             $version->updateRepo();
         }
         // 为了简化svn无trunk, branches时,不需要做查看分支,直接就是主干
         $svnTrunk = sprintf('%s/trunk', Project::getDeployFromDir());
         // svn下无trunk目录
         if (!file_exists($svnTrunk)) {
             $nonTrunk = true;
         }
     }
     if (\Yii::$app->request->getIsPost()) {
         if (!$conf) {
             throw new \Exception(yii::t('task', 'unknown project'));
         }
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 return $this->redirect('/task/');
             }
         }
     }
     if ($projectId) {
         $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
         return $this->render($tpl, ['task' => $task, 'conf' => $conf, 'nonTrunk' => $nonTrunk]);
     }
     // 成员所属项目
     $projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
     return $this->render('select-project', ['projects' => $projects]);
 }
Exemplo n.º 15
0
 /**
  * 配置项目
  *
  * @param $projectId
  * @return string
  * @throws \Exception
  */
 public function actionGroup($projectId)
 {
     // 配置信息
     $project = Project::findOne($projectId);
     if (!$project) {
         throw new \Exception('项目不存在:)');
     }
     if ($project->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的项目:)');
     }
     // 添加用户
     if (\Yii::$app->request->getIsPost() && \Yii::$app->request->post('user')) {
         Group::addGroupUser($projectId, \Yii::$app->request->post('user'));
     }
     // 项目的分组用户
     $group = Group::find()->with('user')->where(['project_id' => $projectId])->indexBy('user_id')->asArray()->all();
     // 所有用户
     $users = User::find()->select(['id', 'email', 'realname'])->where(['is_email_verified' => 1])->asArray()->all();
     return $this->render('group', ['conf' => $project, 'users' => $users, 'group' => $group]);
 }
Exemplo n.º 16
0
 /**
  * filter for group
  * @return array json
  */
 public function actionGroup()
 {
     $fil = Yii::$app->request->post()['name'];
     Yii::$app->response->format = 'json';
     if ($fil && $fil !== 'all') {
         $group = Group::find()->where(['name' => trim($fil)])->one();
         if ($group) {
             if (!empty($group->groupsClients)) {
                 $clients = [];
                 foreach ($group->groupsClients as $key => $gc) {
                     array_push($clients, $gc->client);
                 }
                 return ['errors' => '', 'data' => $this->renderPartial('_clients', ['results' => $clients])];
             }
         }
         return ['errors' => '', 'data' => ''];
     } elseif ($fil && $fil === 'all') {
         return ['errors' => '', 'data' => $this->renderPartial('_clients', ['results' => Client::find()->all()])];
     }
 }
Exemplo n.º 17
0
 /**
  * Validates and deletes the User Group.
  *
  * @author [A. Gianotto] [<snipe@snipe.net]
  * @see GroupsController::getEdit()
  * @param int $id
  * @since [v1.0]
  * @return Redirect
  */
 public function getDelete($id = null)
 {
     if (!config('app.lock_passwords')) {
         try {
             // Get group information
             $group = Group::find($id);
             $group->delete();
             // Redirect to the group management page
             return redirect()->route('groups')->with('success', trans('admin/groups/message.success.delete'));
         } catch (GroupNotFoundException $e) {
             // Redirect to the group management page
             return redirect()->route('groups')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
         }
     } else {
         return redirect()->route('groups')->with('error', trans('general.feature_disabled'));
     }
 }
Exemplo n.º 18
0
/* @var $this yii\web\View */
/* @var $searchModel app\models\ElectionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Добавяне на кандидати';
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = $this->title;
$this->params['electionId'] = $model->id;
?>
<div class="election-index">	

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'first_name', 'last_name', 'email:email', ['attribute' => 'position0.title', 'value' => 'position0.title', 'filter' => Html::activeDropDownList($searchModel, 'position', ArrayHelper::map(Position::find()->asArray()->all(), 'id', 'title'), ['class' => 'form-control', 'prompt' => 'Select Position'])], ['attribute' => 'group0.title', 'value' => 'group0.title', 'filter' => Html::activeDropDownList($searchModel, 'group', ArrayHelper::map(Group::find()->asArray()->all(), 'id', 'title'), ['class' => 'form-control', 'prompt' => 'Select Group	'])], 'unique_id', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{add}', 'buttons' => ['add' => function ($url, $model, $id) {
    return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url, ['title' => Yii::t('app', 'Add Candidate')]);
}], 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'add') {
        $url = Url::to(['/admin/election/add-candidate', 'userId' => $model->id, 'electionId' => $this->params['electionId']]);
        return $url;
    }
}]]]);
?>

</div>
Exemplo n.º 19
0
	

        <?php 
echo $form->field($client, 'firstname', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->textInput(array('placeholder' => 'First Name', 'class' => 'form-control'));
?>
	

        <?php 
echo $form->field($client, 'lastname', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->textInput(array('placeholder' => 'Last Name', 'class' => 'form-control'));
?>
	
		
		<?php 
echo $form->field($client, 'email', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->textInput(array('placeholder' => 'Email', 'class' => 'form-control'));
?>
	

		<?php 
echo $form->field($client, 'birthday', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->textInput(array('placeholder' => 'dd/mm/yyyy', 'class' => 'form-control input-datepicker', 'data-date-format' => 'dd/mm/yyyy'));
?>
	
        
        <?php 
$dataList = ArrayHelper::map(Group::find()->asArray()->all(), 'id', 'name');
?>
		<?php 
echo $form->field($groups, 'id', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->listBox($dataList, ['data-placeholder' => 'Choose some Groups..', 'multiple' => 'multiple', 'class' => 'select-chosen', 'style' => 'display: none', 'id' => 'example-chosen-multiple'])->label('Groups');
?>
    <!-- END General Data Content -->
</div>
Exemplo n.º 20
0
     $group->description = $request->input('description');
     $group->user_id = $user->id;
     $group->save();
     return response()->json($group);
 });
 // Update a group
 $app->put('/group/{id}', function () {
 });
 // Assign user to a group
 $app->post('/group/{id}/user', function (Request $request, $id) {
     $user_id = $request->input('user_id');
     $user = User::find($user_id);
     if (!$user) {
         return response()->json(['status' => 'error', 'message' => 'user-not-found']);
     }
     $group = Group::find($id);
     if (!$group) {
         return response()->json(['status' => 'error', 'message' => 'not-found']);
     }
     // Attach the user to the group
     $group->users()->attach($user);
     return response()->json(['status' => 'okay']);
 });
 // Remove user from group
 $app->delete('/group/{id}/user/{user_id}', function () {
 });
 $app->get('/users', function () {
     $users = User::all();
     return response()->json($users);
 });
 $app->get('/users/{id}', function ($id) {
Exemplo n.º 21
0
 /**
  * Show the form for creating a new resource.
  * GET /statistics/create.
  *
  * @return Response
  */
 public function create($society, $gid)
 {
     $data['group'] = Group::find($gid);
     switch ($data['group']->meeting) {
         case 1:
             $days = '[0,2,3,4,5,6]';
             break;
         case 2:
             $days = '[0,1,3,4,5,6]';
             break;
         case 3:
             $days = '[0,1,2,4,5,6]';
             break;
         case 4:
             $days = '[0,1,2,3,5,6]';
             break;
         case 5:
             $days = '[0,1,2,3,4,6]';
             break;
         case 6:
             $days = '[0,1,2,3,4,5]';
             break;
         case 7:
             $days = '[1,2,3,4,5,6]';
             break;
     }
     $data['days'] = $days;
     $data['society'] = $society;
     return View::make('statistics.create', $data);
 }
Exemplo n.º 22
0
 Mehrfachauswahlfragen<br/>

<h4>Banken</h4>


<?php 
echo \app\models\Bank::find()->count();
?>
 Banken insgesamt, in<br/>
<?php 
echo \app\models\Bank::find()->distinct('klasse')->count();
?>
 verschiedenen Bankenklassen<br/>

<h4>Benutzergruppen</h4>


<?php 
echo \app\models\Group::find()->count();
?>
 Benutzergruppen insgesamt<br/>

<h4>Zugangscodes</h4>
<?php 
echo \app\models\Code::find()->count();
?>
 Verschiedene Zugangscodes, davon<br/>
<?php 
echo \app\models\Code::find()->andFilterWhere(['used' => 1])->count();
?>
 bereits verwendet<br/>
Exemplo n.º 23
0
 /**
  * Lists all Group models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Group::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 24
0
 public function putGrant(Request $request, $id)
 {
     $group = Group::find($id);
     $group->permissions()->sync($request->input('permissions'));
     return back()->with('status', '组 ' . $group->name . ' 权限修改成功');
 }
Exemplo n.º 25
0
        <div class="modal-header our-modal-header">
            <button type="button" class="close" data-dismiss="modal" ><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title our-modal-title" id="myModalLabel">Adicionar Novo Parâmetro</h4>
        </div>
        <div class="modal-body our-modal-body">

            <?php 
$form = ActiveForm::begin();
?>
            
            <?php 
echo $form->field($model, 'id_user')->hiddenInput(array('value' => $_GET['id_user']))->label(false);
?>
            
            <?php 
$groups = ArrayHelper::map(Group::find()->all(), 'id', 'group');
?>
            <?php 
echo $form->field($model, 'id_group')->dropDownList($groups);
?>

            <div class="modal-footer our-modal-footer">
                <div class="form-group our-form-group">
                    <!--<div class="form-group">-->
                    <?php 
echo Html::submitButton($model->isNewRecord ? 'Guardar' : 'Aplicar Alterações', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
                </div>

                <?php 
ActiveForm::end();
Exemplo n.º 26
0
 public function sendMessage($society, $type)
 {
     $soc = Society::find($society);
     $input = Input::all();
     $alldat = array();
     if ($input['leaderoptions'] == "everyone") {
         $allhouseholds = Household::with('individual')->where('society_id', '=', $society)->get();
         foreach ($allhouseholds as $hhh) {
             foreach ($hhh->individual as $iii) {
                 if ($iii->id == $hhh->householdcell) {
                     $dum = self::PopulateRecipient($iii);
                     if ($dum['cellphone'] != "" and $iii->memberstatus == "member") {
                         $alldat[$iii->id] = $dum;
                     }
                 }
             }
         }
     } elseif (isset($input['groups'])) {
         $groups = $input['groups'];
         if ($input['leaderoptions'] == "allmembers") {
             foreach ($groups as $thisgroup) {
                 $group = Group::with('individual')->find($thisgroup);
                 foreach ($group->individual as $indiv) {
                     $dum = self::PopulateRecipient($indiv);
                     $alldat[$indiv->id] = $dum;
                 }
             }
         } elseif ($input['leaderoptions'] == "leadersonly" or $input['leaderoptions'] == "leadersandlist") {
             foreach ($groups as $thisgroup) {
                 $group = Group::with('individual')->find($thisgroup);
                 foreach ($group->individual as $indiv) {
                     if ($group->contact == $indiv->id) {
                         $dum = self::PopulateRecipient($indiv);
                         if (!isset($alldat[$indiv->id])) {
                             $alldat[$indiv->id] = $dum;
                         }
                         if ($input['leaderoptions'] == "leadersandlist") {
                             if (isset($alldat[$indiv->id]['grouplist'])) {
                                 $alldat[$indiv->id]['grouplist'] = $alldat[$indiv->id]['grouplist'] . $group->id . ",";
                             } else {
                                 $alldat[$indiv->id]['grouplist'] = $group->id . ",";
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($input['indivs'])) {
         foreach ($input['indivs'] as $individ) {
             $indiv = Individual::find($individ);
             $dum = self::PopulateRecipient($indiv);
             if (!isset($alldat[$individ])) {
                 $alldat[$individ] = $dum;
             }
         }
     }
     if ($type == "email") {
         if (isset($input['htmlbody'])) {
             $message = nl2br($input['message']) . file_get_contents($input['htmlbody']);
         } else {
             $message = nl2br($input['message']);
         }
         $message = HTML::decode($message);
         $subject = $input['subject'];
         $sender = Input::get('sender');
         Mail::queue('messages.message', array('msg' => $message), function ($message) use($subject, $soc, $alldat, $sender) {
             if (Input::file('attachment')) {
                 $message->attach(Input::file('attachment'), array('as' => Input::file('attachment')->getClientOriginalName(), 'mime' => Input::file('attachment')->getMimeType()));
             }
             foreach ($alldat as $thisrec) {
                 $name = $thisrec['name'];
                 $email = $thisrec['email'];
                 $household = $thisrec['household'];
                 if (isset($thisrec['grouplist'])) {
                     $grouplist = $thisrec['grouplist'];
                 } else {
                     $grouplist = "No group";
                 }
                 $message->from('*****@*****.**', $soc->society . " Methodist Church");
                 $message->to($email, $name)->replyTo($sender);
                 if ($subject == "") {
                     $subject = "Email from " . $soc->society . " Methodist Church";
                 }
                 if ($grouplist != "No group") {
                     $ggl = explode(",", substr($grouplist, 0, -1));
                     foreach ($ggl as $gl) {
                         $repdata = app('App\\Http\\Controllers\\ReportsController')->show($gl, true);
                         $tg = Group::find($gl);
                         $message->attachData($repdata, $tg->groupname . ".pdf");
                     }
                 }
                 $message->subject($subject);
             }
         });
         $results = array();
         foreach ($alldat as $tdat) {
             $result['name'] = $tdat['name'];
             $result['address'] = $tdat['email'];
             $result['household'] = $tdat['household'];
             $results[] = $result;
         }
     } else {
         $final = array();
         foreach ($alldat as $thisdat) {
             $ndx = intval($thisdat['household']);
             if (Input::get('economy') == "household") {
                 if (array_key_exists($ndx, $final)) {
                     $keyhouse = Household::find($ndx)->householdcell;
                     $keycell = Individual::find($keyhouse);
                     if (SMSfunctions::checkcell($keycell->cellphone)) {
                         $final[$ndx]['cellphone'] = $keycell->cellphone;
                         $final[$ndx]['name'] = $keycell->firstname . " " . $keycell->surname;
                         $final[$ndx]['household'] = $ndx;
                     }
                 } else {
                     $final[$ndx]['cellphone'] = $thisdat['cellphone'];
                     $final[$ndx]['name'] = $thisdat['name'];
                     $final[$ndx]['household'] = $ndx;
                 }
             } else {
                 $dummy['cellphone'] = $thisdat['cellphone'];
                 $dummy['name'] = $thisdat['name'];
                 $dummy['household'] = $ndx;
                 $final[] = $dummy;
             }
         }
         if ($soc->sms_provider == "bulksms") {
             if (count($final) > SMSfunctions::BS_get_credits($soc->sms_username, $soc->sms_password)) {
                 return Redirect::back()->withInput()->withErrors("Insufficient Bulk SMS credits to send SMS");
             }
             $url = 'http://community.bulksms.com/eapi/submission/send_sms/2/2.0';
             $port = 80;
         } elseif ($soc->sms_provider == "smsfactory") {
             if (count($final) > SMSfunctions::SF_checkCredits($soc->sms_username, $soc->sms_password)) {
                 return Redirect::back()->withInput()->withErrors("Insufficient SMS Factory credits to send SMS");
             }
         }
         $seven_bit_msg = Input::get('message') . " (From " . substr($soc->society, 0, 1) . "MC)";
         foreach ($final as $sms) {
             if ($soc->sms_provider == "bulksms") {
                 $transient_errors = array(40 => 1);
                 $msisdn = "+27" . substr($sms['cellphone'], 1);
                 $post_body = SMSfunctions::BS_seven_bit_sms($soc->sms_username, $soc->sms_password, $seven_bit_msg, $msisdn);
             }
             $dum2['name'] = $sms['name'];
             $dum2['household'] = $sms['household'];
             if (SMSfunctions::checkcell($sms['cellphone'])) {
                 if ($soc->sms_provider == "bulksms") {
                     $smsresult = SMSfunctions::BS_send_message($post_body, $url, $port);
                 } elseif ($soc->sms_provider == "smsfactory") {
                     $smsresult = SMSfunctions::SF_sendSms($soc->sms_username, $soc->sms_password, $sms['cellphone'], $seven_bit_msg);
                 }
                 $dum2['address'] = $sms['cellphone'];
             } else {
                 if ($sms['cellphone'] == "") {
                     $dum2['address'] = "No cell number provided.";
                 } else {
                     $dum2['address'] = "Invalid cell number: " . $sms['cellphone'] . ".";
                 }
             }
             $results[] = $dum2;
         }
         $data['results'] = $results;
     }
     $data['type'] = $type;
     $data['results'] = $results;
     return View::make('messages.results', $data);
 }
Exemplo n.º 27
0
$this->params['breadcrumbs'][] = ['label' => 'Visualizador', 'url' => array('viewers/update', 'id' => $_GET['viewer_id'], 'viewer_id' => $_GET['viewer_id'])];
$this->params['breadcrumbs'][] = 'Segurança';
?>
<div class="viewer-group-index">

    <p>
        <b>ATENÇÃO:</b> Para ativar protecção ás configurações e/ou layers, tem que adicionar os grupos pretendidos. Caso a tabela não possua nenhum grupo indentificado não será adicionada segurança ao visualizador.
    </p>
    <p>
        <?php 
echo Html::a('Novo Grupo', ['create', 'viewer_id' => $_GET['viewer_id']], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'group_id', 'label' => 'Grupo', 'format' => 'text', 'content' => function ($data) {
    return Group::find()->where("id=" . $data->group_id)->one()->description;
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}', 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'update') {
        $url = array('viewer-group/update', 'id' => $model->id, 'viewer_id' => $model->viewer_id);
        return $url;
    }
    if ($action === 'delete') {
        $url = array('viewer-group/delete', 'id' => $model->id, 'viewer_id' => $model->viewer_id);
        return $url;
    }
}]]]);
?>

</div>
Exemplo n.º 28
0
 public function postSponsor($doc)
 {
     $sponsor = Input::get('sponsor');
     $doc = Doc::find($doc);
     $response = null;
     if (!isset($sponsor)) {
         $doc->sponsor()->sync(array());
     } else {
         switch ($sponsor['type']) {
             case 'user':
                 $user = User::find($sponsor['id']);
                 $doc->userSponsors()->sync(array($user->id));
                 $doc->groupSponsors()->sync(array());
                 $response = $user->toArray();
                 break;
             case 'group':
                 $group = Group::find($sponsor['id']);
                 $doc->groupSponsors()->sync(array($group->id));
                 $doc->userSponsors()->sync(array());
                 $response = $group->toArray();
                 break;
             default:
                 throw new Exception('Unknown sponsor type ' . $sponsor['type']);
         }
     }
     $response['messages'][0] = array('text' => 'Sponsor saved', 'severity' => 'info');
     return Response::json($response);
 }
Exemplo n.º 29
0
 /**
  * List of possible voters groups.
  * @param integer $electionId
  * @return mixed
  */
 public function actionAddGroupList($electionId)
 {
     $model = $this->findModel($electionId);
     $groups = $model->groups;
     foreach ($groups as $group) {
         $groupIds[] = $group->id;
     }
     $dataProvider = new ActiveDataProvider(['query' => Group::find()->where(['not in', 'id', $groupIds])]);
     return $this->render('add-group-list', ['model' => $model, 'dataProvider' => $dataProvider]);
 }
Exemplo n.º 30
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Group;
use app\models\Position;
/* @var $this yii\web\View */
/* @var $model app\models\User */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="user-form">

    <?php 
$groups = Group::find()->asArray()->all();
$groupMap = ArrayHelper::map($groups, 'id', 'title');
$positions = Position::find()->asArray()->all();
$positionMap = ArrayHelper::map($positions, 'id', 'title');
$form = ActiveForm::begin();
?>

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

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

    <?php