示例#1
0
 public function run($args)
 {
     exit('Disabled');
     $Organisations = Organisation::model()->findAll(array('index' => 'id'));
     $command = Yii::app()->db->createCommand("\n\t\t\n\t\tSELECT i.id, i.status, i.date,i.contact_warehouse_id,organisation_id,store2contact_id,query_id, count(*) as 'dupe_count' \n\n\t\tFROM invite i\n\t\t\n\t\tGROUP BY i.contact_warehouse_id, i.organisation_id\n\t\t\n\t\tHAVING dupe_count > 1\n\t\t\n\t\tORDER BY dupe_count DESC\n\t\t\n\t\t");
     $results = $command->queryAll();
     $rows = '';
     $mismatchedOrg = [];
     // 4006
     //$results['contact_warehouse_id'] = 1234;
     //$results['organisation_id'] = 1;
     foreach ($results as $result) {
         // All the s2c rows, with store
         $Store2Contact = Store2Contact::model()->with('store')->find(array('condition' => 'contact_warehouse_id = :cwi AND store.origin_organisation_id = :org_id AND store.date_expired IS NULL', 'params' => array(':cwi' => $result['contact_warehouse_id'], ':org_id' => $result['organisation_id'])));
         if ($result['status'] == 3) {
             $acceeded = 'Y';
         } else {
             $acceeded = 'N';
         }
         // If Sent from Seven Stories, but no
         if ($result['organisation_id'] == 6 && $Store2Contact->store->origin_unique_id == 0) {
             $organisationName = 'Northern Stage (Sent from Seven Stories)';
         } else {
             $organisationName = $Organisations[$result['organisation_id']]->title;
         }
         $rows .= $Store2Contact->store->origin_unique_id . ',' . $result['store2contact_id'] . ',' . $Store2Contact->id . ',' . $organisationName . ',' . $Store2Contact->store->email . ',' . $Store2Contact->store->first_name . ',' . $Store2Contact->store->last_name . ',' . $result['date'] . ',' . $acceeded . "\n";
     }
     $myFile = Yii::app()->basePath . "/../../protected-file-uploads/misc/dupes.csv";
     $fh = fopen($myFile, 'w') or die("can't open file");
     fwrite($fh, $rows);
     fclose($fh);
 }
示例#2
0
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
         switch ($this->_identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $org = Organisation::model()->findByAttributes(array('id' => $this->organisation_id));
                 $user = User::model()->findByAttributes(array('organisation_id' => $this->organisation_id, 'name' => $this->username));
                 Yii::app()->user->setState("org_name", $org['name']);
                 Yii::app()->user->setState("org_id", $org['id']);
                 Yii::app()->user->setState("user_name", $this->username);
                 Yii::app()->user->setState("user_id", $user['id']);
                 $user->last_login = date('Y-m-d');
                 $user->update();
                 //MyUtility::UpdateStatusOfConsumables($user['id']);
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError('username', 'Invalid USERNAME.');
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $this->addError('password', 'Invalid PASSWORD.');
                 break;
         }
     }
 }
示例#3
0
 public function loadModel($id)
 {
     $Model = Organisation::model()->findByPk($id);
     if ($Model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $Model;
 }
示例#4
0
文件: Venue.php 项目: newga/newga
 public function organisationOptions()
 {
     //$a[0]='N/A';
     $organisations = Organisation::model()->findAll(array('condition' => 'active = :active', 'params' => array(':active' => 1)));
     foreach ($organisations as $organisation) {
         $a[$organisation->id] = $organisation->title;
     }
     return $a;
 }
示例#5
0
 public function run($args)
 {
     exit('Disabled');
     ini_set('memory_limit', '512M');
     $Organisations = Organisation::model()->findAll(array('index' => 'id'));
     /*
     $command = Yii::app()->db->createCommand("
     
     SELECT s2c.id, s.email, o.title, CONCAT(i.contact_warehouse_id,organisation_id) AS conc FROM suppression_list sl
     
     INNER JOIN store2contact s2c ON s2c.store_id = sl.store_id
     
     LEFT JOIN store s ON s.id = s2c.store_id
     
     LEFT JOIN invite i ON s2c.id = i.store2contact_id
     
     LEFT JOIN organisation o ON o.id = i.organisation_id
     
     WHERE sl.`date` >= '2014-12-05' AND s.email IS NOT NULL AND type = 1
     
     GROUP BY conc
     
     ");
     */
     $command = Yii::app()->db->createCommand("\n\t\tSELECT i.organisation_id, s2c.contact_warehouse_id, sl.*, s2c.id AS store2contact_id FROM suppression_list sl\n\t\t\n\t\tLEFT JOIN store2contact s2c ON s2c.store_id = sl.store_id\n\t\t\n\t\tLEFT JOIN invite i ON s2c.id = i.store2contact_id\n\t\t\n\t\tWHERE sl.`date` >= '2014-12-05'  AND type = 1\n\t\t\n\t\tGROUP BY sl.store_id\n\t\t");
     $results = $command->queryAll();
     //print count($results) . ' unsubscribes' . "\n\n";
     $rows = '';
     $StoreModel = new Store();
     foreach ($results as $result) {
         $Store2Contact = Store2Contact::model()->with('store')->find(array('condition' => 'contact_warehouse_id = :cwi AND store.origin_organisation_id = :org_id AND store.date_expired IS NULL', 'params' => array(':cwi' => $result['contact_warehouse_id'], ':org_id' => $result['organisation_id'])));
         if (!is_null($Store2Contact)) {
             // If Sent from Seven Stories, but no
             if ($result['organisation_id'] == 6 && $Store2Contact->store->origin_unique_id == 0) {
                 $organisationName = 'Northern Stage (Sent from Seven Stories)';
             } else {
                 $organisationName = $Organisations[$result['organisation_id']]->title;
             }
             $rows .= $Store2Contact->store->origin_unique_id . ',' . $result['store2contact_id'] . ',' . $Store2Contact->id . ',' . $organisationName . ',' . $Store2Contact->store->email . ',' . $Store2Contact->store->first_name . ',' . $Store2Contact->store->last_name . "\n";
         } else {
             print_r($result);
         }
     }
     $myFile = Yii::app()->basePath . "/../../protected-file-uploads/misc/unsubs.csv";
     $fh = fopen($myFile, 'w') or die("can't open file");
     fwrite($fh, $rows);
     fclose($fh);
 }
    public function actionGetorg()
    {
        $name = $_GET['name'];
        $user = User::model()->findByAttributes(array('name' => $name));
        $orgId = $user['organisation_id'];
        $org = Organisation::model()->findByPk($orgId);
        $orgName = $org['name'];
        ?>

        <option value="<?php 
        echo $orgId;
        ?>
"><?php 
        echo $orgName;
        ?>
</option>

        <?php 
    }
示例#7
0
 public function actionRecipients()
 {
     if ((int) $_GET['campaign_id']) {
         // existing sent invite
         $Campaign = Campaign::model()->findByPk($_GET['campaign_id']);
         $Query = $Campaign->query;
     } else {
         throw new CHttpException(404, 'Page not found.');
     }
     $Invites = Invite::model()->findAll(array('condition' => 'query_id = :query_id', 'params' => array(':query_id' => $Query->id), 'with' => array('store2contact', 'store2contact.store')));
     $this->breadcrumbs = array('Invites' => array('index'), $Campaign->name);
     $this->pageTitle = $Campaign->name . ' | Invites | ' . Yii::app()->name;
     // Loop each invite and separate into organisations
     $Organisations = Organisation::model()->findAll(array('condition' => 'id != 10'));
     $organisationsArray = array();
     foreach ($Organisations as $Organisation) {
         $organisationsArray[$Organisation->id]['title'] = $Organisation->title;
         $organisationsArray[$Organisation->id]['invites'] = array();
     }
     foreach ($Invites as $Invite) {
         $organisationsArray[$Invite->organisation_id]['invites'][] = $Invite;
     }
     $this->render('recipients', array('Campaign' => $Campaign, 'organisationsArray' => $organisationsArray));
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     $org = new Organisation();
     // ajax validator
     //if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form')
     //{
     //        echo UActiveForm::validate(array($model,$profile));
     //        Yii::app()->end();
     //}
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         if ($_POST['RegistrationForm']['service'] == 2) {
             ////////////////////////////////////////////////////////////////////////////////
             //$name = trim($org->name);
             $name = trim($_POST['Organisation']['name']);
             $exOrgCount = Organisation::model()->count('name=:param_name', array(':param_name' => $name));
             if ($exOrgCount > 0) {
                 $org->validatorList->add(CValidator::createValidator('unique', $org, 'name', array('message' => Yii::t('app', 'Group Name already exists'))));
             } else {
                 if (strlen($name) == 0) {
                     $org->validatorList->add(CValidator::createValidator('required', $org, 'name', array('message' => Yii::t('app', 'Group Name canot be blank'))));
                 }
             }
             ////////////////////////////////////////////////////////////////////////////////
             echo UActiveForm::validate(array($model, $profile, $org));
             Yii::app()->end();
         } else {
             echo UActiveForm::validate(array($model, $profile));
             Yii::app()->end();
         }
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             $valid = $model->validate();
             $valid = $profile->validate() && $valid;
             if ($_POST['RegistrationForm']['service'] == 2) {
                 $org->name = trim($_POST['Organisation']['name']);
                 $valid = $org->validate() && $valid;
             }
             //if($model->validate()&&$profile->validate())
             if ($valid) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 $orgDuplicateCheck = false;
                 $flag = true;
                 $role = 'Authenticated';
                 if ($model->service == 1) {
                     $orgDuplicateCheck = true;
                     $role = 'Individual';
                 } else {
                     if ($model->service == 2 && isset($_POST['Organisation']['name'])) {
                         $org->name = trim($_POST['Organisation']['name']);
                         $flag = Organisation::model()->exists('name=:param_name_check', array(':param_name_check' => $org->name));
                         if (!$flag) {
                             $orgDuplicateCheck = true;
                         }
                         $role = 'Org_Admin';
                     } else {
                         //$org->validatorList->add(CValidator::createValidator('unique', $org, 'name', array('message'=>Yii::t('app','Group Name Already Exists'))));
                         $org->validate();
                         Yii::app()->user->setFlash('registration', UserModule::t("Group Name already exists"));
                     }
                 }
                 if ($orgDuplicateCheck) {
                     if ($model->save()) {
                         $profile->user_id = $model->id;
                         $profile->firstname = $model->firstname;
                         $profile->lastname = $model->lastname;
                         $profile->save();
                         $this->assignRole($model->id, $role);
                         //If Service=2 ~ Organisation Save New (Non-Existent) Organisation
                         if (!$flag) {
                             $org->created_by = $model->id;
                             $org->type = 'Other';
                             //$org->timestamp_create = date('Y-m-d H:i:s');
                             if ($org->save()) {
                                 $model->organisation_id = $org->id;
                                 $model->organisation_administrator = 1;
                                 $model->save(false);
                                 try {
                                     //Create Organisation Group
                                     $group = new Group();
                                     $group->group_name = $org->name;
                                     $group->parent_group_id = 0;
                                     $group->organisation_id = $org->id;
                                     $group->timestamp_created = date('Y-m-d H:i":');
                                     $group->save(false);
                                     $groupMember = new GroupMember();
                                     $groupMember->group_id = $group->group_id;
                                     $groupMember->user_id = $model->id;
                                     $groupMember->manager_flag = 1;
                                     //$groupMember->created_by = 0;
                                     //$groupMember->timestamp_created = date('Y-m-d H:i:s');
                                     $groupMember->save(false);
                                 } catch (Exception $ex) {
                                     Yii::log($ex->getMessage(), 'error', 'Custom');
                                 }
                             } else {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Oop! Soemthing Went Wrong"));
                             }
                         }
                         if (Yii::app()->controller->module->sendActivationMail) {
                             $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                             UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate your account by going to {activation_url}", array('{activation_url}' => $activation_url)));
                         }
                         if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                             $identity = new UserIdentity($model->username, $soucePassword);
                             $identity->authenticate();
                             Yii::app()->user->login($identity, 0);
                             $this->redirect(Yii::app()->controller->module->returnUrl);
                         } else {
                             if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                             } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                             } elseif (Yii::app()->controller->module->loginNotActiv) {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email to login."));
                             } else {
                                 //Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email."));
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your spam/junk folder if you email is not in inbox."));
                             }
                             $this->refresh();
                         }
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile, 'org' => $org));
     }
 }
示例#9
0
 public function actionUploadOutcome($id)
 {
     // ensure csv line endings are correctly recognised.
     ini_set('auto_detect_line_endings', true);
     $Campaign = Campaign::model()->with(array('outcomes' => array('index' => 'id')))->findByPk($id);
     if (!sizeof($Campaign->outcomes)) {
         Yii::app()->user->setFlash('Warning', 'This campaign has no outcomes and as such cannot be updated via file upload.');
     }
     // check for upload file
     if (sizeof($Campaign->outcomes) && sizeof($_FILES['file']) && strlen($_FILES['file']['tmp_name'])) {
         // confirm the organisation.
         if (Yii::app()->user->role < User::ROLE_MANAGER) {
             $organisation_id = Yii::app()->user->organisation_id;
         } else {
             // should have one in post.
             if (!is_numeric($_POST['organisation_id'])) {
                 throw new CHttpException('400', 'Bad Request - missing organisation_id');
             }
             $organisation_id = (int) $_POST['organisation_id'];
         }
         $Organisation = Organisation::model()->findByPk($organisation_id);
         // check outcome belongs to campaign
         if (!array_key_exists($_POST['outcome_id'], $Campaign->outcomes)) {
             // not a valid outcome
             throw new CHttpException('400', 'Bad Request - invalid outcome.');
         }
         //get the csv file
         $fh = fopen($_FILES['file']['tmp_name'], "r");
         // store number of successes so we can tell rows and individual columns;
         $successes = [];
         //loop through the csv file and gather unique ids
         for ($lines = 0; $data = fgetcsv($fh); $lines++) {
             if (strlen($data[0])) {
                 $uniqueIDs[] = $data[0];
             }
         }
         if (!sizeof($uniqueIDs)) {
             exit('no uniques');
         }
         $CDbCriteria = new CDbCriteria();
         $CDbCriteria->join = 'INNER JOIN store2contact ON `t`.warehouse_id = `store2contact`.`contact_warehouse_id`';
         $CDbCriteria->addCondition('`t`.`campaign_id` = :campaign_id');
         $CDbCriteria->addCondition('`store2contact`.origin_id = :origin_organisation_id');
         $CDbCriteria->params = array(':campaign_id' => $Campaign->id, ':origin_organisation_id' => (int) $_POST['organisation_id']);
         $CDbCriteria->compare('`store2contact`.`origin_unique_id`', $uniqueIDs);
         $CDbCriteria->index = 'id';
         $CampaignContacts = CampaignContact::model()->findAll($CDbCriteria);
         // update all who match against a campaign contact 2 outcome
         if (sizeof($CampaignContacts)) {
             // do update on those rows
             CampaignContact2Outcome::model()->updateAll(array('outcome' => date("Y-m-d H:i:s")), "campaign_contact_id IN (" . implode(", ", array_keys($CampaignContacts)) . ")\n\t\t\t\t\t\tAND campaign_outcome_id = :campaign_outcome_id\n\t\t\t\t", array(':campaign_outcome_id' => $_POST['outcome_id']));
         }
         // at least something got updated.
         Yii::app()->user->setFlash('success', sizeof($CampaignContacts) . ' (of ' . $lines . ') rows provided a matching contact to allow outcome update.');
         $this->refresh();
     }
     $this->pageTitle = 'Upload Campaign Outcome Users | ' . Yii::app()->name;
     $this->breadcrumbs = array('Campaigns' => array('index'), $Campaign->name => array('campaign/createUpdate', 'id' => $Campaign->id), 'Upload Campaign Outcome Users');
     // show form
     $this->render('uploadOutcome', array('Campaign' => $Campaign));
 }
示例#10
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'form-upload-outcomes', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'col-sm-6')));
?>

<?php 
if (Yii::app()->user->role >= User::ROLE_MANAGER) {
    // have to choose organisation
    ?>
	<div class="form-group">
		<label><?php 
    echo 'Organisation contacts belong to:';
    ?>
</label>
		<?php 
    echo CHtml::dropDownList('organisation_id', null, CHtml::listData(Organisation::model()->findAll(array('condition' => "view_name != 'Store'", 'order' => 'title')), 'id', 'title'), array('class' => 'form-control', (sizeof($Outcomes) ? 'not' : '') . 'disabled' => 'disabled'));
    ?>
	</div>
<?php 
}
// if manager or super
?>
	<div class="form-group">
		<label><?php 
echo 'Manual outcome to update:';
?>
</label>
		<?php 
echo CHtml::dropDownList('outcome_id', null, CHtml::listData($Outcomes, 'id', 'name'), array('class' => 'form-control', (sizeof($Outcomes) ? 'not' : '') . 'disabled' => 'disabled'));
?>
	</div>
示例#11
0
文件: rules.php 项目: newga/newga
				<td>
					<?php 
    print $row->bool_choice ? $Question->positiveLang : $Question->negativeLang;
    ?>
					<?php 
    print $Question->question;
    switch ($Question->option_id) {
        case QueryQuestion::OPTION_VENUE:
            if (is_null($Venues)) {
                $Venues = Venue::model()->findAll(array('condition' => 'active = 1', 'index' => 'id'));
            }
            print ' ' . $Venues[$row->query_option];
            break;
        case QueryQuestion::OPTION_ORGANISATION:
            if (is_null($Organisations)) {
                $Organisations = Organisation::model()->findAll(array('condition' => 'active = 1', 'index' => 'id'));
            }
            print ' ' . $Organisations[$row->query_option]->title;
            break;
        case QueryQuestion::OPTION_INVITE:
            if (is_null($InviteQueries)) {
                $InviteQueries = Query::model()->findAll(array('condition' => 'invite = 1', 'index' => 'id'));
            }
            print ' ' . $InviteQueries[$row->query_option]->name;
            break;
        case QueryQuestion::OPTION_CS:
            if (is_null($CultureSegments)) {
                $CultureSegments = CultureSegment::model()->findAll(array('index' => 'id'));
            }
            print ' ' . $CultureSegments[$row->query_option]->name;
            break;
示例#12
0
 /**
  * download a reminder of your organisations data structure file requirements
  * an upload template if you will
  */
 public function actionStructureReminder()
 {
     if (Yii::app()->user->organisation_id) {
         $Organisation = Organisation::model()->findByPk(Yii::app()->user->organisation_id);
         $View = $Organisation->view_name;
         $dbColumns = Yii::app()->db->schema->getTable($View::tableName())->columns;
         $csv = fopen('php://output', 'w');
         header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
         header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header('Content-Encoding: UTF-8');
         header('Content-type: text/csv; charset=UTF-8');
         // disposition / encoding on response body
         header("Content-Disposition: attachment;filename=insider_data_format.csv");
         header("Content-Transfer-Encoding: binary");
         foreach ($dbColumns as $dbColumn) {
             if ($dbColumn->name === 'id') {
                 continue;
             }
             $columns[] = $dbColumn->name;
         }
         // add row
         fputcsv($csv, $columns);
         fclose($csv);
         exit;
     }
 }
示例#13
0
?>
		<?php 
echo $form->passwordField($model, 'password');
?>
		<?php 
echo $form->error($model, 'password');
?>
		
	</div>
        
        <div>
                <?php 
echo $form->labelEx($model, 'organisation_id', array('class' => 'inline-labels'));
?>
                <?php 
echo $form->dropDownList($model, 'organisation_id', CHtml::listData(Organisation::model()->findAll(), 'id', 'name'), array('span' => 2, 'prompt' => '---'));
?>
                <?php 
echo $form->error($model, 'organisation_id');
?>
        </div>

	<div class="rememberMe">
		<?php 
echo $form->checkBox($model, 'rememberMe');
?>
		<?php 
echo $form->label($model, 'rememberMe', array('class' => 'form-label'));
?>
		<?php 
echo $form->error($model, 'rememberMe');
示例#14
0
文件: index.php 项目: newga/newga
<div class="row">
	<div class="col-xs-12">
		<?php 
echo CHtml::link('Create new User', array('user/create'), array('class' => 'btn btn-primary pull-right'));
?>
	</div>
</div>


<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'blog-grid', 'dataProvider' => $User->search(), 'filter' => $User, 'filterCssClass' => 'form-controls', 'pagerCssClass' => 'yiipager', 'itemsCssClass' => 'table table-bordered table-striped table-hover table-responsive', 'pager' => array('header' => false, 'htmlOptions' => array('class' => 'pagination'), 'hiddenPageCssClass' => 'disabled', 'maxButtonCount' => 3, 'cssFile' => false), 'cssFile' => false, 'columns' => array(array('name' => 'filterFullName', 'type' => 'html', 'value' => function ($User) {
    if ($User->mothballed) {
        return '<span class="text-muted">' . CHtml::encode($User->FullName) . ' (archived)</span>';
    }
    return CHtml::encode($User->FullName);
}), array('name' => 'role', 'type' => 'html', 'value' => function ($User) {
    if ($User->mothballed) {
        return '<span class="text-muted">' . CHtml::encode($User->AdminType) . ' (archived)</span>';
    }
    return CHtml::encode($User->AdminType);
}), array('name' => 'organisation_id', 'type' => 'html', 'value' => function ($User) {
    if ($User->mothballed) {
        return '<span class="text-muted">' . $User->OrganisationName . ' (archived)</span>';
    }
    return $User->OrganisationName;
}, 'filter' => CHtml::listData(Organisation::model()->findAll(array('condition' => 'id != 10')), 'id', 'title')), array('header' => 'Edit', 'filter' => false, 'type' => 'html', 'value' => function ($User) {
    if ($User->mothballed) {
        return '';
    }
    return CHtml::link('Edit', array('user/update', 'id' => $User->id), array('class' => 'btn btn-default'));
}, 'htmlOptions' => array('class' => 'center', 'style' => 'width: 40px;')))));
示例#15
0
<?php 
if (Yii::app()->user->hasFlash('error')) {
    ?>
	<div class="alert alert-danger"><?php 
    print Yii::app()->user->getFlash('error');
    ?>
</div>
<?php 
}
?>

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'upload-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>
		
		<label>File</label>
		<input type="file" name="csv" />
		<hr>
		<label>Organisation</label><br />
		<?php 
print CHtml::dropDownList('organisation_id', $_POST['organisation_id'], CHtml::listData(Organisation::model()->findAll(array('condition' => 'id != 10')), 'id', 'title'), array('prompt' => '-- Choose --'));
?>
		<hr>
		
		
		<input type="submit" class="btn btn-primary" name="import" value="Upload and Process">
<?php 
$this->endWidget();
?>

示例#16
0
文件: run.php 项目: newga/newga
        if (strlen($person['dob'])) {
            $date = new DateTime($person['dob']);
            $now = new DateTime();
            $interval = $now->diff($date);
            $numberSpread[$interval->y]++;
        }
        $person['origin_organisation_id'];
        $originSpread[$person['origin_organisation_id']]++;
        if (!$person['culture_segment']) {
            $person['culture_segment'] = 'Unknown';
        }
        $cultureSpread[$person['culture_segment']]++;
    }
    //sort by key
    ksort($numberSpread);
    $Organisations = Organisation::model()->findAllByAttributes(array('id' => array_keys($originSpread)), array('index' => 'id'));
    foreach ($originSpread as $key => $value) {
        $originSpreadTitles[$Organisations[$key]->title] = $value;
    }
}
// !sizeof($people)
?>
<div class="query-infographics">
<?php 
if (Yii::app()->controller->getRoute() != 'site/dashboard') {
    ?>
<div class="page-header">
	<h1><?php 
    echo CHtml::encode($Query->name);
    ?>
</h1>
示例#17
0
<?php

$this->breadcrumbs = array(UserModule::t('Users') => array('admin'), $model->username);
$this->menu = array(array('label' => UserModule::t('Create User'), 'url' => array('create')), array('label' => UserModule::t('Update User'), 'url' => array('update', 'id' => $model->id)), array('label' => UserModule::t('Delete User'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => UserModule::t('Are you sure to delete this item?'))), array('label' => UserModule::t('Manage Users'), 'url' => array('admin')));
?>
<h1><?php 
echo UserModule::t('View User') . ' "' . $model->username . '"';
?>
</h1>

<?php 
$attributes = array('id', 'username');
$profileFields = ProfileField::model()->forOwner()->sort()->findAll();
if ($profileFields) {
    foreach ($profileFields as $field) {
        array_push($attributes, array('label' => UserModule::t($field->title), 'name' => $field->varname, 'type' => 'raw', 'value' => $field->widgetView($model->profile) ? $field->widgetView($model->profile) : ($field->range ? Profile::range($field->range, $model->profile->getAttribute($field->varname)) : $model->profile->getAttribute($field->varname))));
    }
}
array_push($attributes, 'password', 'email', 'activkey', 'firstname', 'lastname', 'timezone', array('name' => 'service', 'value' => $model->service == 1 ? 'Individual' : 'Organisation'), array('name' => 'visible_to_public', 'value' => $model->visible_to_public > 0 ? 'Yes' : 'No'), array('header' => 'Organisation', 'name' => 'organisation_id', 'value' => $model->organisation_id > 0 ? Organisation::model()->findByPk($model->organisation_id) != null ? Organisation::model()->findByPk($model->organisation_id)->name : "None" : 'None'), array('name' => 'organisation_administrator', 'value' => $model->organisation_administrator > 0 ? 'Yes' : 'No'), 'create_at', 'lastvisit_at', array('name' => 'superuser', 'value' => User::itemAlias("AdminStatus", $model->superuser)), array('name' => 'status', 'value' => User::itemAlias("UserStatus", $model->status)));
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attributes));
示例#18
0
 public function sendTest($toEmail, $subject, $body)
 {
     // In test mode, we should send 9 emails - one from each organisation
     // The subject and body content should be as it is in the form, except we won't have a full URL, so we can use an example
     // Parse content including tags
     $parsedContent = $this->parseEmailContent($subject, $body, array('first_name' => '%recipient.first_name%', 'last_name' => '%recipient.last_name%', 'invite_url' => '%recipient.invite_url%', 'unsubscribe_url' => '%recipient.unsubscribe_url%'));
     $responses = array();
     // Let's load all the organisations, we'll need them later
     $Organisations = Organisation::model()->findAll(array('condition' => 'id != :id', 'params' => array(':id' => 10), 'index' => 'id'));
     $mailgunApi = new MailgunApi(Yii::app()->params['insiderEmailDomain'], Yii::app()->params['mailgun']['key']);
     // Loop the organisations and send an email for each one
     foreach ($Organisations as $Organisation) {
         if (strlen($Organisation->email_template)) {
             $message = $mailgunApi->newMessage();
             $message->setFrom('email@' . Yii::app()->params['insiderEmailDomain'], Yii::app()->name);
             $message->addTo($toEmail, Yii::app()->user->first_name . ' ' . Yii::app()->user->last_name, array('first_name' => Yii::app()->user->first_name, 'last_name' => Yii::app()->user->last_name, 'invite_url' => 'http://example.com/#-invite-url-', 'unsubscribe_url' => 'http://example.com/#-unsubscribe-url-'));
             $message->setSubject($parsedContent['subject']);
             $message->addTag('test');
             $renderedView = Yii::app()->controller->renderPartial('//mail/organisation-templates/' . $Organisation->email_template, array('body' => $parsedContent['body']), true);
             $message->setHtml($renderedView);
             $response = $message->send();
             if ($response['id']) {
                 $responses[] = $response['id'];
             } else {
                 $errors[] = $response;
             }
         } else {
         }
     }
     if (!sizeof($errors)) {
         Yii::app()->user->setFlash('success', sizeof($responses) . ' test emails sent. Check the inbox of ' . $_POST['Campaign']['email_test_recipient']);
     } else {
         Yii::app()->user->setFlash('error', 'There was an error sending some or all of the emails. ' . sizeof($responses) . ' test were emails sent. ' . $errors . ' were unset due to errors. Check the inbox of ' . $_POST['Campaign']['email_test_recipient']);
     }
     //$this->refresh();
 }
示例#19
0
文件: _options.php 项目: newga/newga
                }
                ?>
  ><?php 
                echo $Venue->title;
                ?>
</option>
<?php 
            }
            break;
            // Organisation
        // Organisation
        case QueryQuestion::OPTION_ORGANISATION:
            ?>
				<option>Select Organisation...</option>
<?php 
            $Organisations = Organisation::model()->findAll(array('condition' => 'active = 1', 'order' => 'title ASC'));
            foreach ($Organisations as $Organisation) {
                ?>

				<option data-id="<?php 
                echo $Organisation->id;
                ?>
" value="<?php 
                echo $Organisation->id;
                ?>
" <?php 
                if ($query_option == $Organisation->id) {
                    echo 'selected="selected"';
                }
                ?>
  ><?php 
示例#20
0
文件: upload.php 项目: newga/newga
<?php

/*
View to allow campaign outcome upload
*/
$dropDownData = CHtml::listData(Organisation::model()->findAll("view_name != ''"), "id", "title");
// loop good and back flashes and show them.
foreach (Yii::app()->user->getFlashes() as $state => $message) {
    ?>
<p class="alert alert-<?php 
    echo $state;
    ?>
"><?php 
    echo $message;
    ?>
</p><?php 
}
?>
	<div class="page-header">
		<h2>Upload Campaign Contacts and Outcomes</h2>
	</div>
	<p>Upload a csv containing manual outcome information for campaign contacts for the campaign "<?php 
echo $Campaign->name;
?>
".</p>
	<p>The format should match the campaign snapshot download file and each row must contain a campaign_contact_id and <span style="font-family:courier;background:#ddd;padding:0 4px;">dd/mm/yyyy hh:mm</span> or <span style="font-family:courier;background:#ddd;padding:0 4px;">yyyy-mm-dd hh:mm</span> style datetime strings for those outcomes to be marked as complete.</p>
	<p>Only outcome data will be recorded and only when a date time is supplied.</p>
<pre>
campaign_contact_id | outcome_44 - Name of outcome | outcome_45 - Second outcome name | outcome_46 - Outcome 3
123                 | 2015-04-02 10:34             | 02/04/15 12:55                   | 03-04-15 19:34
</pre>
示例#21
0
<span>
    <?php 
switch ($Question->option_id) {
    // Venue
    case QueryQuestion::OPTION_VENUE:
        $Venue = Venue::model()->findByPk($query_option);
        print $Venue->title;
        break;
        // Organisation
    // Organisation
    case QueryQuestion::OPTION_ORGANISATION:
        $Organisation = Organisation::model()->findByPk($query_option);
        print $Organisation->title;
        break;
        // Invite
    // Invite
    case QueryQuestion::OPTION_INVITE:
        $InviteQuery = Query::model()->findByPk($query_option);
        print $InviteQuery->name;
        break;
        // Culture Segment
    // Culture Segment
    case QueryQuestion::OPTION_CS:
        $CultureSegment = CultureSegment::model()->findByPk($query_option);
        print $CultureSegment->name;
        break;
        // Artforms
    // Artforms
    case QueryQuestion::OPTION_ARTFORM:
        $Artforms = Artform::model()->findByPk($query_option);
        print $Artform->title;