public function finish($data, $form)
 {
     parent::finish($data, $form);
     $steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
     if ($steps) {
         foreach ($steps as $step) {
             if ($step->class == 'Page2PersonalDetailsFormStep') {
                 $member = new Member();
                 $data = $step->loadData();
                 if ($data) {
                     $member->update($data);
                     $member->write();
                 }
             }
             if ($step->class == 'Page2OrganisationDetailsFormStep') {
                 $organisation = new Organisation();
                 $data = $step->loadData();
                 if ($data) {
                     $organisation->update($data);
                     if ($member && $member->ID) {
                         $organisation->MemberID = $member->ID;
                     }
                     $organisation->write();
                 }
             }
             // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
         }
     }
     $controller = $this->getController();
     $controller->redirect($controller->Link() . 'finished');
 }
예제 #2
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);
 }
예제 #3
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;
         }
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, $faker->numberBetween(5, 10)) as $index) {
         Organisation::create(['name' => $faker->company, 'lrsUser' => $faker->userName, 'lrsPass' => Hash::make('password')]);
     }
 }
 public static function fromArray($data)
 {
     $collection = new static();
     foreach ($data as $key => $value) {
         $collection->items[$key] = Organisation::fromArray($value);
     }
     return $collection;
 }
예제 #6
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;
 }
예제 #7
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;
 }
 public function postDelete($id)
 {
     if (Organisation::destroy($id)) {
         $this->notifySuccess('Organisation Deleted.');
     } else {
         $this->notifyError('Organisation Deletion Failed.');
     }
     return Redirect::route(self::HOME);
 }
 public function get_update()
 {
     $gallery = Gallery::Find($this->gallery_id);
     $organisations = Organisation::get();
     $selected_org = array();
     foreach ($gallery->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.galleries.update')->with('gallery', $gallery)->with('organisations', $organisations)->with('selected_org', $selected_org);
 }
 public function get_update()
 {
     $category = Category::find($this->category_id);
     $organisations = Organisation::get();
     $selected_org = array();
     foreach ($category->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.categories.update')->with('category', $category)->with('organisations', $organisations)->with('selected_org', $selected_org);
 }
 public function get_update()
 {
     $testimonial = Testimonial::Find($this->testimonial_id);
     $organisations = Organisation::get();
     $selected_org = array();
     foreach ($post->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.testimonials.update')->with('testimonial', $testimonial)->with('organisations', $organisations)->with('selected_org', $selected_org);
 }
예제 #12
0
 public function run()
 {
     $faker = Faker::create();
     foreach (Organisation::get() as $org) {
         foreach (range(1, $faker->numberBetween(1, 10)) as $index) {
             $attribute = new Attr(['name' => $faker->domainWord]);
             $attribute = $org->attrs()->save($attribute);
         }
     }
 }
예제 #13
0
 public function run()
 {
     $faker = Faker::create();
     foreach (Organisation::get() as $org) {
         foreach (range(1, $faker->numberBetween(1, 10)) as $index) {
             $learner = new Learner(['name' => $faker->name, 'identifier' => $faker->email]);
             $learner = $org->learners()->save($learner);
         }
     }
 }
예제 #14
0
 public function run()
 {
     $faker = Faker::create();
     $faker->seed(1234);
     foreach (Organisation::get() as $org) {
         foreach (range(1, $faker->numberBetween(1, 10)) as $index) {
             $tutor = new Tutor(['name' => $faker->name, 'email' => $faker->email, 'password' => 'password']);
             $tutor = $org->tutors()->save($tutor);
         }
     }
 }
예제 #15
0
 public function get_update()
 {
     $page = Page::Find($this->page_id);
     $user = Auth::user();
     $organisations = Organisation::get();
     $selected_org = array();
     foreach ($page->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.pages.update')->with('page', $page)->with('user', $user)->with('organisations', $organisations)->with('selected_org', $selected_org);
 }
 public function php($data)
 {
     $valid = parent::php($data);
     $uniquefield = $this->uniquefield;
     $organisation = Organisation::get()->filter($uniquefield, $data[$uniquefield])->first();
     if ($uniquefield && is_object($organisation) && $organisation->isInDB()) {
         $uniqueField = $this->form->Fields()->dataFieldByName($uniquefield);
         $this->validationError($uniqueField->id(), sprintf(_t('Member.VALIDATIONORGANISATIONEXISTS', 'An organisation already exists with the same %s'), strtolower($uniquefield)), 'required');
         $valid = false;
     }
     return $valid;
 }
 protected function processRecord($record, $columnMap, &$results, $preview = false)
 {
     //TODO: skip empties
     $this->extend('preprocess', $record, $columnMap, $results, $preview);
     $id = parent::processRecord($record, $columnMap, $results, $preview);
     if ($org = Organisation::get()->byID($id)) {
         $org->write();
         //callback for doing other custom stuff
         $this->extend('postprocess', $org, $record, $columnMap, $results, $preview);
         $org->destroy();
         unset($org);
     }
     return $id;
 }
예제 #18
0
 public function get_update()
 {
     $faq = Faq::find($this->faq_id);
     $faqcategories = Faqcategory::get();
     $organisations = Organisation::get();
     $selected = array();
     foreach ($faq->faqcategories as $c) {
         $selected[] = $c->id;
     }
     $selected_org = array();
     foreach ($faq->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.faqs.update')->with('faq', $faq)->with('faqcategories', $faqcategories)->with('organisations', $organisations)->with('selected_org', $selected_org)->with('selected', $selected);
 }
예제 #19
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);
 }
예제 #20
0
 public function get_update()
 {
     $post = Post::Find($this->post_id);
     $user = Auth::user();
     $categories = Category::get();
     $organisations = Organisation::get();
     $selected = array();
     foreach ($post->categories as $c) {
         $selected[] = $c->id;
     }
     $selected_org = array();
     foreach ($post->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.posts.update')->with('post', $post)->with('user', $user)->with('categories', $categories)->with('selected', $selected)->with('organisations', $organisations)->with('selected_org', $selected_org);
 }
    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 
    }
예제 #22
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));
 }
예제 #23
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>
예제 #24
0
     break;
 case 'update':
     $opts = filter_input_array(INPUT_POST, array("associated_organisation_id" => FILTER_SANITIZE_NUMBER_INT, "associated_group" => FILTER_SANITIZE_STRING, "associated_role" => FILTER_SANITIZE_STRING, "associated_cat_id" => FILTER_SANITIZE_NUMBER_INT));
     if (!$opts["associated_cat_id"]) {
         add_error("Invalid or unspecified Category.");
         header("HTTP/1.0 500 Internal Error");
         echo display_status_messages(false);
         exit;
     } else {
         $category = MetaDataType::get($opts["associated_cat_id"]);
     }
     if (!$opts["associated_organisation_id"]) {
         add_error("Invalid or unspecified Organisation");
     } else {
         $organisation_id = $opts["associated_organisation_id"];
         $organisation = Organisation::get($organisation_id);
     }
     if (!$opts["associated_group"]) {
         add_error("Invalid or unspecified Group");
     } else {
         $group = $opts["associated_group"];
     }
     if ($opts["associated_role"] == "all") {
         $role = null;
     } else {
         $role = $opts["associated_role"];
     }
     if (!has_error()) {
         $caching = MetaDataValues::get($organisation_id, $group, $role, null, $category);
         //first go through the values array and verify that all of the indices are correct
         $indices = filter_var(array_keys($_POST['value']), FILTER_VALIDATE_INT, array("flags" => FILTER_REQUIRE_ARRAY));
예제 #25
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;
     }
 }
 public function getChangeServiceType($user_id)
 {
     $profile = Subscriber::findOrFail($user_id);
     $orgs = Organisation::lists('name', 'id');
     return View::make("admin.accounts.change-service-type")->with('profile', $profile)->with('orgs', $orgs);
 }
 /**
  * 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));
     }
 }
 protected function getOrganisationFromRequest()
 {
     return Organisation::get()->byID((int) $this->request->param('ID'));
 }
예제 #29
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>
예제 #30
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));
 }