public function loadFromRawData($data, $reset = false) { if ($reset) { $this->initValues(); } $excluded_properties = array('product', 'developer', 'organization'); foreach (array_keys($data) as $property) { if (in_array($property, $excluded_properties)) { continue; } // form the setter method name to invoke setXxxx $setter_method = 'set' . ucfirst($property); if (method_exists($this, $setter_method)) { $this->{$setter_method}($data[$property]); } else { self::$logger->notice('No setter method was found for property "' . $property . '"'); } } if (isset($data['organization'])) { $organization = new Organization($this->config); $organization->loadFromRawData($data['organization']); $this->organization = $organization; } if (isset($data['product'])) { $product = new Product($this->config); $product->loadFromRawData($data['product']); $this->products[] = $product; } if (isset($data['developer'])) { $developer = new Developer($this->config); $developer->loadFromRawData($data['developer']); $this->developer = $developer; } }
/** * set up for dependent objects before running each test */ public final function setUp() { //run default set-up method parent::setUp(); //create a new organization for the test volunteers to belong $organization = new Organization(null, "123 Easy Street", '', "Albuquerque", "Feeding people since 1987", "9 - 5", "Food for Hungry People", "505-765-4321", "NM", "R", "87801"); $organization->insert($this->getPDO()); //create a new volunteer to use as an admin for the tests //don't need to insert them into the database: just need their info to create sessions //for testing purposes, allow them to create organizations they're not associated with $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("sha512", "password4321", $salt, 262144, 128); $this->admin = new Volunteer(null, $organization->getOrgId(), "*****@*****.**", null, "John", $hash, true, "Doe", "505-123-4567", $salt); $this->admin->insert($this->getPDO()); //create a non-admin volunteer for the tests $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("sha512", "password1234", $salt, 262144, 128); $this->volunteer = new Volunteer(null, $organization->getOrgId(), "*****@*****.**", null, "Jane", $hash, false, "Doe", "505-555-5555", $salt); $this->volunteer->insert($this->getPDO()); //create the guzzle client $this->guzzle = new \GuzzleHttp\Client(["cookies" => true]); //visit ourselves to get the xsrf-token $this->guzzle->get('https://bootcamp-coders.cnm.edu/~tfenstermaker/bread-basket/public_html/php/api/organization'); $cookies = $this->guzzle->getConfig()["cookies"]; $this->token = $cookies->getCookieByName("XSRF-TOKEN")->getValue(); //send a request to the sign-in method $adminLogin = new stdClass(); $adminLogin->email = "*****@*****.**"; $adminLogin->password = "******"; $login = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~tfenstermaker/bread-basket/public_html/php/controllers/sign-in-controller.php', ['json' => $adminLogin, 'headers' => ['X-XSRF-TOKEN' => $this->token]]); }
public function doApprove() { $exist = Member::get()->filter(array('Email' => $this->Email))->first(); if ($exist) { return false; } $member = new Member(); $data = $this->toMap(); unset($data['ID']); unset($data['ClassName']); unset($data['UnapprovedMember']); $member->update($data); $member->write(); if ($this->MemberType === 'Organization') { $member->addToGroupByCode('organization'); $organization = new Organization(); $organization->AccountID = $member->ID; $organization->company_name = $this->OrganizationName; $organizationID = $organization->write(); $member->OrganizationID = $organizationID; $member->write(); } else { $member->addToGroupByCode('personal'); } $this->setField('Approved', true); $this->write(); return true; }
/** * Signup a new account with the given parameters * * @param array $input Array containing 'username', 'email' and 'password'. * * @return User User object that may or may not be saved successfully. Check the id to make sure. */ public function signup($input) { // $name = array_get($input, 'organization'); $org = new Organization(); $lcode = $org->encode($name); $organization = Organization::find(array_get($input, 'organization_id')); $organization->licensed = 100; $organization->license_code = $lcode; $organization->update(); $user = new User(); $user->username = array_get($input, 'username'); $user->email = array_get($input, 'email'); $user->password = array_get($input, 'password'); $user->user_type = array_get($input, 'user_type'); $user->username = array_get($input, 'username'); $user->organization_id = '1'; // The password confirmation will be removed from model // before saving. This field will be used in Ardent's // auto validation. $user->password_confirmation = array_get($input, 'password_confirmation'); // Generate a random confirmation code $user->confirmation_code = md5(uniqid(mt_rand(), true)); // Save if valid. Password field will be hashed before save $this->save($user); return $user; }
function create() { $organization = new Organization(); $organization->name = $_POST['name']; if ($organization->save()) { $this->redirect('/organizations', 'Criado com sucesso!'); } else { $this->redirect('/organizations', 'Falha na criação!'); } }
public function run() { $organization = new Organization(); $organization->name = 'Helpster'; $organization->date_established = '2015-02-24'; $organization->description = 'Helpster is a site dedicated to link volunteer organizations to prospecting volunteers'; $organization->website = 'http://helpster.site'; $organization->image = 'helpster.png'; $organization->user_id = 4; $organization->save(); }
public function findOrCreateOrganization() { $organization = $this->owner->Organization(); if ($organization->ID) { return $organization; } $organization = new Organization(); $organization->write(); $organization->Members()->add($this->owner); return $organization; }
public function update(Organization $org) { $name = trim(Input::get('name')); $redirect = Redirect::route('settings', $org->slug); if ($name) { $org->name = $name; $org->css = Input::get('css', []); $org->save(); return $redirect->withSuccess('Organization updated successfully'); } else { return $redirect->withError('Name may not be blank'); } }
public function run($id, $type, $getSub = false) { $controller = $this->getController(); $controller->title = "RESSOURCES"; $controller->subTitle = "Toutes les ressources de nos associations"; $controller->pageTitle = ucfirst($controller->module->id) . " - " . $controller->title; if ($type == Organization::COLLECTION) { $organizations = array(); $organization = Organization::getById($id); $organizations[$id] = $organization['name']; } $documents = Document::getWhere(array("type" => $type, "id" => $id, "contentKey" => array('$exists' => false))); if ($getSub && $type == Organization::COLLECTION && Authorisation::canEditMembersData($id)) { $subOrganization = Organization::getMembersByOrganizationId($id, Organization::COLLECTION); foreach ($subOrganization as $key => $value) { $organization = Organization::getById($key); $organizations[$key] = $organization['name']; $documents = array_merge($documents, Document::getWhere(array("type" => $type, "id" => $key, "contentKey" => array('$exists' => false)))); } } $categories = Document::getAvailableCategories($id, $type); $params = array("documents" => $documents, "id" => $id, "categories" => $categories, "organizations" => $organizations, "getSub" => $getSub); if (Yii::app()->request->isAjaxRequest) { echo $controller->renderPartial("documents", $params, true); } else { $controller->render("documents", $params); } }
/** * Update an information field for an organization */ public function run() { $organizationId = ""; $res = array("result" => false, "msg" => Yii::t("common", "Something went wrong!")); if (!empty($_POST["pk"])) { $organizationId = $_POST["pk"]; } else { if (!empty($_POST["id"])) { $organizationId = $_POST["id"]; } } if ($organizationId != "") { if (!empty($_POST["name"]) && !empty($_POST["value"])) { $organizationFieldName = $_POST["name"]; $organizationFieldValue = $_POST["value"]; try { Organization::updateOrganizationField($organizationId, $organizationFieldName, $organizationFieldValue, Yii::app()->session["userId"]); $res = array("result" => true, "msg" => Yii::t("organisation", "The organization has been updated"), $organizationFieldName => $organizationFieldValue); } catch (CTKException $e) { $res = array("result" => false, "msg" => $e->getMessage(), $organizationFieldName => $organizationFieldValue); } } } Rest::json($res); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $organization = Organization::find($id); $organization->delete(); Session::flash('successMessage', 'Your delete was successful.'); return Redirect::action('OrganizationsController@index'); }
public function run() { $events = array(); $organization = Organization::getPublicData($id); if (isset($organization["links"]["events"])) { foreach ($organization["links"]["events"] as $key => $value) { $event = Event::getPublicData($key); $events[$key] = $event; } } foreach ($organization["links"]["members"] as $newId => $e) { if ($e["type"] == Organization::COLLECTION) { $member = Organization::getPublicData($newId); } else { $member = Person::getPublicData($newId); } if (isset($member["links"]["events"])) { foreach ($member["links"]["events"] as $key => $value) { $event = Event::getPublicData($key); $events[$key] = $event; } } } Rest::json($events); }
public function postGeneral($id) { $id = Crypt::decrypt($id); $request = RRequest::find($id); if (Input::has('save')) { if (Input::get('employee') == 0 || Input::get('organization') == 0 || Input::get('r_plan') == 0 || Input::get('specialist') == 0 || strlen(Input::get('title')) < 2 || strlen(Input::get('description')) < 2) { Session::flash('sms_warn', trans('sta.require_field')); } else { $request->request_by_id = Input::get('employee'); $request->for_organization_id = Input::get('organization'); $request->for_planning_id = Input::get('r_plan'); $request->to_department_id = Input::get('specialist'); $request->request_title = Input::get('title'); $request->description = Input::get('description'); $request->request_date = date('Y-m-d'); $request->created_by = Auth::user()->employee_id; if ($request->save()) { Session::flash('sms_success', trans('sta.save_data_success')); //return Redirect::to('branch_request/general/' . Crypt::encrypt($request->id)); } } } $organizations = $this->array_list(Organization::list_item()); $employees = $this->array_list(Employee::list_item()); $department = $this->array_list(Department::list_item()); $r_plans = $this->array_list(Rplan::list_item()); return View::make('branch_request.edit_general', array('id' => $id, 'organizations' => $organizations, 'employees' => $employees, 'specialist' => $department, 'r_plans' => $r_plans, 'request' => $request)); }
public function getOrgDocs($id) { $organization = Organization::find($id); $user = Organization::find($id)->user(); $documents = User::find($organization->user->id)->documents; return View::make('inspector.documents_view', ['organization' => $organization, 'user' => $user, 'documents' => $documents]); }
public static function balanceSheet($date) { $accounts = Account::all(); $organization = Organization::find(1); $pdf = PDF::loadView('pdf.financials.balancesheet', compact('accounts', 'date', 'organization'))->setPaper('a4')->setOrientation('potrait'); return $pdf->stream('Balance Sheet.pdf'); }
public function PersonalRegisterForm() { $fields = FieldList::create(array(EmailField::create('Email', '电子邮件'), ConfirmedPasswordField::create('Password', '密码'), TextField::create('FullName', '姓名'), TextField::create('IDCard', '身份证号码'), TextField::create('Phone', '联系电话'), DropdownField::create('OrganizationID', '所属单位名称', Organization::get()->map('ID', 'company_name'))->setEmptyString('请选择'))); $actions = FieldList::create(array(FormAction::create('doRegisterPersonal', '提交'))); $required = RequiredFields::create(array('Email', 'Password', 'FullName', 'IDCard', 'Phone', 'OrganizationID')); $form = new Form($this, __FUNCTION__, $fields, $actions, $required); return $form; }
public function testGetMe() { $at = getenv("BB_ACCESS_TOKEN"); $o = Organization::get($at); $this->assertInstanceOf('\\ClausConrad\\BillysBilling\\Organization', $o, 'Getting own organization returns an Organization instance.'); $this->assertNotNull($o->id, 'Own organization has an organization ID.'); $this->assertNotEmpty($o->id, 'Own organization has an organization ID'); }
public function __call($method, $parameters) { $morphed = $this->getOrganizationConfig('division.morphed'); if (array_key_exists($method, $morphed)) { return $this->morphedByMany($morphed[$method], 'divisionable'); } return parent::__call($method, $parameters); }
/** * @param integer $id the ID of the model to be loaded * @return Organization the loaded model * @throws CHttpException */ protected function loadModel($id) { $model = Organization::model()->findByPk($id); if ($model === NULL) { $this->show404(); } return $model; }
/** * Query * * @param array $args * @return Doctrine_Query $q */ protected function air_query($args = array()) { $org_id = $this->parent_rec->org_id; $q = Doctrine_Query::create()->from('Organization o'); $q->where('o.org_parent_id = ?', $org_id); Organization::add_counts($q, 'o'); return $q; }
public function run($insee = null) { $controller = $this->getController(); $where = array("address.codeInsee" => $insee); $params["events"] = Event::getWhere($where); $params["organizations"] = Organization::getWhere($where); $params["people"] = Person::getWhere($where); $controller->render("directory", $params); }
public static function createOrg($opts) { $organization = \Organization::saveRecord(null, array("name" => $opts['user']->name)); $centre = new \Centre(array("user_id" => $opts['user']->id, "organization_id" => $organization->id, "type" => "clinic", "department" => json_encode(RequestMethods::post("department", array("Clinic"))), "phone" => RequestMethods::post("org_phone", ""), "location_id" => $opts['location']->id)); $centre->save(); $member = new \Member(array("user_id" => $opts['user']->id, "centre_id" => $centre->id, "organization_id" => $organization->id, "designation" => "admin", "image" => "", "live" => 1)); $member->save(); return $organization; }
public function payments() { $payments = Payment::all(); $erporders = Erporder::all(); $erporderitems = Erporderitem::all(); $organization = Organization::find(1); $pdf = PDF::loadView('erpreports.paymentsReport', compact('payments', 'erporders', 'erporderitems', 'organization'))->setPaper('a4')->setOrientation('potrait'); return $pdf->stream('Payment List.pdf'); }
public static function createLeaveType($data) { $organization = Organization::getUserOrganization(); $leavetype = new Leavetype(); $leavetype->name = array_get($data, 'name'); $leavetype->days = array_get($data, 'days'); $leavetype->organization()->associate($organization); $leavetype->save(); }
public static function createHoliday($data) { $organization = Organization::getUserOrganization(); $holiday = new Holiday(); $holiday->name = array_get($data, 'name'); $holiday->date = array_get($data, 'date'); $holiday->organization()->associate($organization); $holiday->save(); }
public function run() { $controller = $this->getController(); //$res = array( "result" => false , "content" => Yii::t("common", "Something went wrong!") ); if (isset($_POST["id"])) { $project = isset($_POST["id"]) ? PHDB::findOne(PHType::TYPE_PROJECTS, array("_id" => new MongoId($_POST["id"]))) : null; if ($project) { if (preg_match('#^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,6}$#', $_POST['email'])) { if ($_POST['type'] == "citoyens") { $member = PHDB::findOne(PHType::TYPE_CITOYEN, array("email" => $_POST['email'])); $memberType = PHType::TYPE_CITOYEN; } else { $member = PHDB::findOne(Organization::COLLECTION, array("email" => $_POST['email'])); $memberType = Organization::COLLECTION; } if (!$member) { if ($_POST['type'] == "citoyens") { $member = array('name' => $_POST['name'], 'email' => $_POST['email'], 'invitedBy' => Yii::app()->session["userId"], 'tobeactivated' => true, 'created' => time()); $memberId = Person::createAndInvite($member); $isAdmin = isset($_POST["contributorIsAdmin"]) ? $_POST["contributorIsAdmin"] : false; if ($isAdmin == "1") { $isAdmin = true; } else { $isAdmin = false; } } else { $member = array('name' => $_POST['name'], 'email' => $_POST['email'], 'invitedBy' => Yii::app()->session["userId"], 'tobeactivated' => true, 'created' => time(), 'type' => $_POST["organizationType"]); $memberId = Organization::createAndInvite($member); $isAdmin = false; } $member["id"] = $memberId["id"]; Link::connect($memberId["id"], $memberType, $_POST["id"], PHType::TYPE_PROJECTS, Yii::app()->session["userId"], "projects", $isAdmin); Link::connect($_POST["id"], PHType::TYPE_PROJECTS, $memberId["id"], $memberType, Yii::app()->session["userId"], "contributors", $isAdmin); $res = array("result" => true, "msg" => Yii::t("common", "Your data has been saved"), "member" => $member, "reload" => true); } else { if (isset($project['links']["contributors"]) && isset($project['links']["contributors"][(string) $member["_id"]])) { $res = array("result" => false, "content" => "member allready exists"); } else { $isAdmin = isset($_POST["contributorIsAdmin"]) ? $_POST["contributorIsAdmin"] : false; if ($isAdmin == "1") { $isAdmin = true; } else { $isAdmin = false; } Link::connect($member["_id"], $memberType, $_POST["id"], PHType::TYPE_PROJECTS, Yii::app()->session["userId"], "projects", $isAdmin); Link::connect($_POST["id"], PHType::TYPE_PROJECTS, $member["_id"], $memberType, Yii::app()->session["userId"], "contributors", $isAdmin); $res = array("result" => true, "msg" => Yii::t("common", "Your data has been saved"), "member" => $member, "reload" => true); } } } else { $res = array("result" => false, "content" => "email must be valid"); } } } Rest::json($res); }
function actionOrganization() { $this->checkLogin(); $model = Organization::model()->find(); if (!empty($_POST)) { $model->attributes = $_POST["Organization"]; // show logo on bill $org_logo_show_on_bill = "no"; $logo_show_on_header = "no"; $logo_show_on_header_bg = "no"; if (!empty($_POST['logo_show_on_header'])) { $logo_show_on_header = Util::input($_POST['logo_show_on_header']); } if (!empty($_POST['org_logo_show_on_bill'])) { $org_logo_show_on_bill = Util::input($_POST['org_logo_show_on_bill']); } if (!empty($_POST['logo_show_on_header_bg'])) { $logo_show_on_header_bg = Util::input($_POST['logo_show_on_header_bg']); } $on_bill = 'no'; if ($org_logo_show_on_bill == 1) { $on_bill = 'yes'; } $model->org_logo_show_on_bill = $on_bill; $model->logo_show_on_header = $logo_show_on_header; $model->logo_show_on_header_bg = $logo_show_on_header_bg; // logo if (!empty($_FILES['Organization'])) { $org_logo = $_FILES['Organization']; $name = $org_logo['name']['org_logo']; $tmp = $org_logo['tmp_name']['org_logo']; $size = $org_logo['size']['org_logo']; if ($size > 0) { $ext = explode(".", $name); $ext = $ext[count($ext) - 1]; $ext = strtolower($ext); $name = microtime(); $name = str_replace(" ", "", $name); $name = str_replace(".", "", $name); if ($ext == "jpg" || $ext == "png") { $newName = "{$name}.{$ext}"; if (move_uploaded_file($tmp, "upload/{$newName}")) { // remove old file $oldName = $model->org_logo; if (file_exists('upload/' . $oldName)) { @unlink('upload/' . $oldName); } $model->org_logo = $name . "." . $ext; } } } } $model->save(); } $this->render("//Config/Organization", array('model' => $model)); }
public function run() { DB::table('todos')->truncate(); foreach (Organization::all() as $org) { Todo::create(['name' => 'First Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id, 'completed' => true]); Todo::create(['name' => 'Second Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id]); Todo::create(['name' => 'Todo from Second', 'user_id' => $org->users[1]->id, 'organization_id' => $org->id]); Todo::create(['name' => 'Third Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id]); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $rsvps = Rsvp::where('user_id', '=', Auth::user()->id)->get(); $organizations = Organization::get(); $user = Auth::user(); if (empty($user->first_name) || empty($user->last_name) || empty($user->zip)) { return Redirect::action('UsersController@edit', [$user->id]); } return View::make('users.index')->with('rsvps', $rsvps); }
public function stock() { $items = Item::all(); $organization = Organization::find(1); $pdf = PDF::loadView('erpreports.stockReport', compact('items', 'organization'))->setPaper('a4')->setOrientation('potrait'); return $pdf->stream('Stock Report.pdf'); }