/** * Display a listing of the resource. * * @return Response */ public function index() { //We have to change the All() method! All is not good! $companies = Company::get(['id', 'fancy_name', 'rut']); $role = check_admin_auth(); return View::make('companies.index', compact('role', 'companies')); }
public function work() { $job = new Job(); $job->getByUid($this->user->id); if ($job->hasWorked()) { throw new Exception('you have already worked'); } $company = new Company(); $company->get($job->company); //check if is in the same region if ($this->user->region != $company->region) { throw new Exception("You are not in the same region as company"); } //check if company has funds enough if ($company->money < $job->salary) { throw new Exception("The company doesn't have funds enough"); } $worked = $job->work(); //add extra data before return if ($worked) { $data = $this->parse($job); $data = array_merge($data, $worked); return $data; } else { return false; } }
/** * @param FieldList $fields * @return FieldList|void */ public function updateCMSFields(FieldList $fields) { $oldFields = $fields->toArray(); foreach ($oldFields as $field) { $fields->remove($field); } $fields->push(new LiteralField("Title", "<h2>Training</h2>")); $fields->push(new TextField("Name", "Name")); $fields->push(new HtmlEditorField("Overview", "Overview")); $fields->push(new CheckboxField("Active", "Active")); $types = TrainingCourseType::get(); $levels = TrainingCourseLevel::get(); $companies = Company::get(); if ($companies) { $fields->push(new DropdownField('CompanyID', 'Company', $companies->map("ID", "Name", "Please Select a Company"))); } if ($types && $levels && $this->owner->ID > 0) { $config = GridFieldConfig_RecordEditor::create(); $courses = new GridField('Courses', 'Courses', $this->owner->Courses(), $config); $fields->push($courses); } else { $fields->push(new LiteralField("Warning", "** You can not add any Training Course until you create some Training Course Levels and Training Course Types!.")); } return $fields; }
function CompanyCount() { $Count = Company::get()->filter('DisplayOnSite', true)->count(); // Round down to nearest multiple of 5 $Count = round(($Count - 2.5) / 5) * 5; return $Count; }
function save($data, $form) { $response = new OSLogoProgramResponse(); $form->saveInto($response); // Combine these two fields so we just store a manually typed name in // $data[OtherCompany] if ($data['NonSponsorCompany']) { $response->OtherCompany = $data['NonSponsorCompany']; } $response->write(); // Now set the official company name for the email $data['CompanyName'] = 'Not Provided'; if ($response->OtherCompany) { $response->CompanyName = $response->OtherCompany; } elseif ($response->CompanyID != 0) { $company = Company::get()->byID($response->CompanyID); if ($company) { $response->CompanyName = $company->Name; } } // Email the logo email list $Subject = "Contact Form for Commercial Logo Inquiries"; $email = EmailFactory::getInstance()->buildEmail($data['Email'], OS_LOGO_PROGRAM_FORM_TO_EMAIL, $Subject); $email->setTemplate('OSLogoProgramResponseEmail'); $email->populateTemplate($response); $email->send(); if ($response->Program === 'Powered') { Controller::curr()->setMessage('success', 'Thanks for your interest in licensing the OpenStack Powered logo. Please review the interoperability standards at <a href="http://www.openstack.org/interop" class="alert-link">openstack.org/interop</a> page and submit test results according to the instructions.'); } return Controller::curr()->redirect(Controller::curr()->Link("thanks")); }
/** * Display all resources in storage. * * @return Response */ public function showAll() { $companies = Company::get(); // foreach ($company as $value) { // echo $value->company_type; // } return View::make('front_end/main')->with('companies', $companies); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { if (!check_admin_auth()) { return Redirect::action('SessionsController@create'); } $role = check_admin_auth(); $companies = Company::get(['id', 'fancy_name']); $providers = Provider::get(['id', 'fancy_name']); return View::make('registrations.create', compact('role', 'providers', 'companies')); }
public function get() { $id = (int) $_REQUEST['id']; if ($id == 0) { throw new Exception('missing data'); } $companyClass = new Company(); $company = $companyClass->get($id); return $this->parse($company); }
function testSave() { $c = new Company(); $this->assertFalse($c->id, 'should not have an id yet'); $c->set(array('name' => 'save_test')); $c->save(); $this->assertTrue($c->id, 'should have an id'); $this->assertEqual($c->get('name'), 'save_test', 'name should be save_test'); $c2 = new Company($c->id); $this->assertEqual($c2->get('name'), 'save_test', ' reloaded item name should also be save_test'); }
public function updateCMSFields(FieldList $fields) { $oldFields = $fields->toArray(); foreach ($oldFields as $field) { $fields->remove($field); } $fields->push(new TextField("MaxInstances", "Max. Instances")); $companies = Company::get(); if ($companies) { $fields->push($ddl = new DropdownField('CompanyID', 'Company', $companies->map("ID", "Name"))); $ddl->setEmptyString("Please Select a Company"); } $market_place_types = MarketPlaceType::get(); if ($market_place_types) { $fields->push($ddl = new DropdownField('MarketPlaceTypeID', 'MarketPlaceType', $market_place_types->map("ID", "Name"))); $ddl->setEmptyString("Please Select a Market Place Type"); } return $fields; }
function getAdminPermissionSet(array &$res) { $companyId = $_REQUEST["CompanyId"]; if (isset($companyId) && is_numeric($companyId) && $companyId > 0) { // user could be ccla admin of only one company and company must have at least one team set $ccla_group = Group::get()->filter('Code', ICLAMember::CCLAGroupSlug)->first(); if (!$ccla_group) { return; } $query_groups = new SQLQuery(); $query_groups->addSelect("GroupID"); $query_groups->addFrom("Company_Administrators"); $query_groups->addWhere("MemberID = {$this->owner->ID} AND CompanyID <> {$companyId} AND GroupID = {$ccla_group->ID} "); $groups = $query_groups->execute()->keyedColumn(); $company = Company::get()->byID($companyId); if (count($groups) === 0 && $company->isICLASigned()) { array_push($res, 'CCLA_ADMIN'); } } }
public function getCMSFields() { $fields = new FieldList(); $fields->push(new CheckboxField("ContractSigned", "Contract Signed")); $contract_start = new DateField("ContractStart", "Contract Start"); $fields->push(new TextField("EchosignID", "Echosign ID")); $contract_start->setConfig('showcalendar', true); $fields->push($contract_start); $contract_end = new DateField("ContractEnd", "Contract End"); $contract_end->setConfig('showcalendar', true); $fields->push($contract_end); $companies = Company::get(); if ($companies) { $fields->push(new DropdownField('CompanyID', 'Company', $companies->map("ID", "Name", "Please Select a Company"))); } $templates = ContractTemplate::get(); if ($templates) { $fields->push(new DropdownField('ContractTemplate', 'Template', $templates->map("ID", "Name", "Please Select a Contract Template"))); } return $fields; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); if (!$migration) { $programs = DB::query('SELECT P.*,C.CompanyID from TrainingProgram P INNER JOIN Contract C on C.ID = P.TrainingContractID;'); $service = new TrainingManager(new SapphireTrainingServiceRepository(), new SapphireMarketPlaceTypeRepository(), new MarketPlaceTypeAddPolicyStub(), null, new CacheServiceStub(), new MarketplaceFactory(), SapphireTransactionManager::getInstance()); $factory = new TrainingFactory(); foreach ($programs as $program) { $company_id = (int) $program['CompanyID']; $company = Company::get()->byID($company_id); $program_id = (int) $program['ID']; $training = $factory->buildTraining($program['Name'], $program['Description'], true, $company); $training->CompanyID = $company_id; $training->write(); //get former courses and associate it with new entity $courses = TrainingCourse::get()->filter('ProgramID', $program_id); if ($courses && count($courses) > 0) { foreach ($courses as $course) { $course->TrainingServiceID = $training->getIdentifier(); $course->write(); } } } //db alter DB::query('DROP TABLE Training;'); DB::query('ALTER TABLE `TrainingCourse` DROP COLUMN ProgramID;'); DB::query('DROP TABLE TrainingProgram;'); $new_training_group_slug = ITraining::MarketPlaceGroupSlug; DB::query("\n\t\t\tUPDATE `Company_Administrators`\n\t\t\tSET GroupID = (SELECT ID FROM `Group` WHERE code='{$new_training_group_slug}' LIMIT 1 )\n\t\t\tWHERE ID IN (\n\t\t\t\tSELECT tmp.id FROM\n\t\t\t\t(\n\t\t\t\t\tSELECT ID FROM `Company_Administrators`\n\t\t\t\t\tWHERE GroupID IN ( SELECT ID FROM `Group` where code='training-admins')\n\t\t\t\t) as tmp\n\t\t\t);\n\t\t\t"); DB::query("\n\t\t\tDELETE Permission\n\t\t\tFROM Permission\n\t\t\tWHERE Code='MANAGE_COMPANY_TRAINING';\n\t\t\t"); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function doUp() { global $database; if (DBSchema::existsTable($database, "JobPage")) { $res = DB::query("SELECT * FROM JobPage;"); foreach ($res as $record) { $new_job = new Job(); $new_job->ID = (int) $record['ID']; $new_job->Title = $record['Title']; $new_job->Description = $record['Content']; $new_job->Created = $record['Created']; $new_job->LastEdited = $record['LastEdited']; $new_job->PostedDate = $record['JobPostedDate']; $new_job->ExpirationDate = $record['ExpirationDate']; // company name logic $company_name = $record['JobCompany']; $company = Company::get()->filter('Name', $company_name)->first(); $new_job->CompanyID = is_null($company) ? 0 : $company->ID; if ($new_job->CompanyID == 0) { $new_job->CompanyName = $company_name; } $new_job->MoreInfoLink = $record['JobMoreInfoLink']; $new_job->Location = $record['JobLocation']; $new_job->IsFoundationJob = $record['FoundationJob']; $new_job->IsActive = $record['Active']; $new_job->Instructions2Apply = $record['JobInstructions2Apply']; $new_job->LocationType = $record['LocationType']; $new_job->IsCOANeeded = 0; $new_job->TypeID = 0; //registration request $registration_request = JobRegistrationRequest::get()->filter('Title', $new_job->Title)->first(); if (!is_null($registration_request)) { $new_job->RegistrationRequestID = $registration_request->ID; } $new_job->write(); } DBSchema::dropTable($database, "JobPage"); } }
public function __construct($name, $title, $value = null) { $this->name = $name; $this->title = $title; $children = new FieldList(); $source = Company::get()->sort('Name')->map('ID', 'Name')->toArray(); $source['0'] = "-- New Company --"; $children->add($ddl = new DropdownField($name . '_id', $title, $source)); $ddl->setEmptyString('-- Select Your Company --'); $ddl->addExtraClass('select-company-name'); if (!is_null($value)) { $c = Company::get()->filter('Name', $value)->first(); if ($c) { $ddl->setValue($c->ID); } } $children->add($txt = new TextField($name, '')); $txt->addExtraClass('input-company-name'); parent::__construct($children); $control_css_class = strtolower('company-composite'); $this->addExtraClass($control_css_class); Requirements::javascript('openstack/code/utils/CustomHTMLFields/js/company.field.js'); Requirements::customScript("\n jQuery(document).ready(function(\$) {\n \$('.'+'{$control_css_class}').company_field();\n });"); }
function CompanyCount() { $DisplayedCompanies = Company::get()->filter('DisplayOnSite', 1); $Count = $DisplayedCompanies->Count(); return $Count; }
function LookForExistingURLSegment($URLSegment) { return Company::get()->filter(array('URLSegment' => $URLSegment, 'ID:not' => $this->ID))->first(); }
public static function getCompany() { $c = Company::get(); self::$role = $c; return new self(); }
public function getOrganization($forceRefresh = false) { if ($forceRefresh) { $this->organization = null; } if ($this->company_id === null) { return null; } else { if ($this->organization === null) { //let's cache org entity $this->organization = Company::get($this->company_id); } } return $this->organization; }
echo "<script>window.location='../../'</script>"; } }); $app->put('/users/:id', function ($id) use($user, $app) { if (isset($_SESSION['app']) && isset($_COOKIE['app'])) { $request = $app->request(); $body = $request->getBody(); $data = json_decode($body); $data->id = $id; $user->update($data); } else { echo "<script>window.location='../../'</script>"; } }); $app->get('/company', function () use($company) { $company->get(); }); $app->put('/company/:id', function () use($company, $app) { if (isset($_SESSION['app']) && isset($_COOKIE['app'])) { $request = $app->request(); $body = $request->getBody(); $data = json_decode($body); $company->update($data); } else { echo "<script>window.location='../../'</script>"; } }); $app->post('/email', function () use($email) { $email->sendEmail(); }); $app->get('/email', function () use($email) {
/** * Generates units from user work and pays his salary * * @return mixed (boolean/array) */ public function work() { /* http://wiki.e-sim.org/index.php/Productivity_formula * P = 10 * (4+E) * N * C * R * Q P - Productivity E - Economy skill level N - Employee multiplier (Number of employees already worked that day in the company.) if employeesWorked <=10 Then N = 1.0 + (10-employeesWorked) * 0.05 elseif employeesWorked <=20 Then N = 1.0 - (employeesWorked-10) * 0.03 elseif employeesWorked <=30 Then N = 0.7 - (employeesWorked-20) * 0.02 else N=0.5; C 1 If home country controls capital 0.75 If not R for manufacture companies: 1.25 If region's country owns the appropriate high raw. (eg: Iron for Weapons) 1 If region's country do not own the appropriate high raw. for raw companies: 1.0 in high regions 0.75 in medium region. Q 1.0 for manufacture companies for raw companies 1.0 for Q1 companies 1.2 for Q2 companies 1.4 for Q3 companies 1.6 for Q4 companies 1.8 for Q5 companies * */ $job = new Job(); $job = $job->getByUid($this->uid); if (!$job) { throw new Exception("you don't have a job"); } $skills = new Skill(); $skills->get($this->uid); $E = $skills->economic; $employeesWorked = 1; //ToDO PENDING if ($employeesWorked <= 10) { $N = 1.0 + (10 - $employeesWorked) * 0.05; } elseif ($employeesWorked <= 20) { $N = 1.0 - ($employeesWorked - 10) * 0.03; } elseif ($employeesWorked <= 30) { $N = 0.7 - ($employeesWorked - 20) * 0.02; } else { $N = 0.5; } $company = new Company(); $company->get($job->company); $region = new Region(); $companyRegion = $region->get($company->region); //does the region have the resource that company produces? // also determine product quality if ($company->productType == Company::PRODUCT_TYPE_RESOURCE) { $R = $companyRegion->resourceAmount / 10; $Q = 1; } else { $product = new Product(); $product->get($company->product); if ($companyRegion->resourceType == $product->resource) { $R = 1.25; } else { $R = 1; } $Q = 0.8 + 0.2 * $company->quality; } $country = new Country(); $country = $country->get($companyRegion->country); $capitalRegion = $region->get($country->capitalRegionId); //is country capital owned by original owners? if ($capitalRegion->country == $capitalRegion->countryConqueror) { $C = 1; } else { $C = 0.75; } if ($companyRegion->resourceAmount > 0) { $productivity = 10 * (4 + $E) * $N * $C * $R * $Q; } else { $productivity = 10 * (4 + $E) * $N * $C * $Q; } $user = new User($this->uid); $user->updateXP('WORK'); $skills->economic += 0.125; $skills->save(); $company->pendingUnits += $productivity; //calculate produced units if ($company->productType == Company::PRODUCT_TYPE_RESOURCE) { $createdUnits = floor($company->pendingUnits); $company->pendingUnits -= $createdUnits; $added = $company->addStock($createdUnits, Company::PRODUCT_TYPE_PRODUCT); if ($added) { $company->save(); } } else { $minProduct = $product->productivityBase * $company->quality; $createdUnits = floor($company->pendingUnits / $minProduct); if ($company->pendingUnits > $minProduct) { } $company->pendingUnits -= $createdUnits * $minProduct; $added = $company->addStock($createdUnits, Company::PRODUCT_TYPE_PRODUCT); if ($added) { $company->save(); } } //pay salary $transactionData = array('quantity' => $job->salary, 'action' => 'PAY_SALARY', 'receiver' => $this->uid, 'receiverType' => Company::RECEIVER_TYPE_USER); if ($company->transaction($transactionData)) { //save historial Service::getDB()->insert('work_historial', array('uid' => $this->uid, 'date' => $this->now())); return array('productivity' => $productivity, 'createdUnits' => $createdUnits); } else { return false; } }
function CurrentCompany() { $CompanyID = Session::get('CompanyID'); if ($CompanyID && is_numeric($CompanyID)) { $Company = Company::get()->byID((int) $CompanyID); return $Company; } return null; }
public function getManagedCompanies() { $query = DB::query("SELECT Company.* from Company INNER JOIN Company_Administrators ON Company_Administrators.CompanyID=Company.ID AND Company_Administrators.MemberID={$this->owner->ID} INNER JOIN (\r\n SELECT DISTINCT(GroupID) FROM `Permission` WHERE `Code` IN\r\n ('MANAGE_COMPANY_PROFILE','MANAGE_COMPANY_LOGOS') ) PG ON PG.GroupID = Company_Administrators.GroupID"); $companies = new ArrayList(); if (!is_null($query) && $query->numRecords() > 0) { for ($i = 0; $i < $query->numRecords(); $i++) { $record = $query->nextRecord(); $companies->push(new $record['ClassName']($record)); } } $old_companies = Company::get()->filter(array('CompanyAdminID' => $this->owner->ID)); $joined_companies = new ArrayList(); if ($companies && $companies->Count() > 0) { foreach ($companies as $company) { $joined_companies->push($company); } } if ($old_companies && $old_companies->Count() > 0) { foreach ($old_companies as $company) { $joined_companies->push($company); } } return $joined_companies; }
public function action_index() { if (!Group::current('allow_assign')) { throw new HTTP_Exception_403('Forbidden'); } $ids = array_keys(Arr::get($_POST, 'job', array())); $type = intval(Arr::get($_POST, 'type')); $company = intval(Arr::get($_POST, 'company')); if (!$ids) { Messages::save('Please, select at least one job!'); } elseif (!$type) { Messages::save('Please, select works type!'); } elseif (!$company) { Messages::save('Please, select company!'); } elseif (DB::select('id')->from('job_types')->where('id', '=', $type)->execute()->get('id') && ($company == -1 || DB::select('id')->from('companies')->where('id', '=', $company)->execute()->get('id'))) { $assign_time = time(); $jobs = Database_Mongo::collection('jobs'); $result = $jobs->find(array('_id' => array('$in' => $ids))); $count = 0; $values = array(); $users = array(); while ($job = $result->next()) { if (Arr::path($job, 'assigned.' . $type) != $company) { $update = array(); if (Arr::path($job, 'assigned.' . $type)) { $users = DB::select('id')->from('users')->where('company_id', '=', $job['assigned'][$type])->execute()->as_array(NULL, 'id'); $subs = Database_Mongo::collection('submissions')->findOne(array('job_key' => $job['_id'], 'active' => 1, 'user_id' => array('$in' => $users))); if ($subs) { continue; } else { $subs = Database_Mongo::collection('submissions')->find(array('job_key' => $job['_id'], 'active' => -1))->sort(array('process_time' => 1)); $list = array(); foreach ($subs as $sub) { $list[$sub['key']] = $sub['_id']; } $financial = DB::select('id')->from('job_columns')->where('financial', '>', 0)->execute()->as_array(NULL, 'id'); $res = array(); foreach ($financial as $column) { if (isset($list['data.' . $column])) { $res[$column] = $list['data.' . $column]; } } Database_Mongo::collection('submissions')->update(array('_id' => array('$in' => array_values($res))), array('$set' => array('financial_time' => 0)), array('multiple' => 1)); if (!in_array($job['assigned'][$type], Arr::get($job, 'ex', array()), true)) { $job['ex'][] = intval($job['assigned'][$type]); $update['$set']['ex'] = $job['ex']; } } } if ($company == -1) { unset($job['assigned'][$type]); } else { $job['assigned'][$type] = $company; $update['$set']['data.266'] = $assign_time; } if (Arr::get($job, 'assigned')) { $update['$set']['assigned'] = $job['assigned']; } else { $update['$unset']['assigned'] = 1; } $update['$set']['last_update'] = $assign_time; $companies = array(); if (Arr::get($job, 'assigned')) { foreach ($job['assigned'] as $cmp) { if ($cmp) { $companies[$cmp] = 1; } } } $update['$set']['companies'] = array_keys($companies); $status = Arr::get($job, 'status', Enums::STATUS_UNALLOC); if (in_array($status, array(Enums::STATUS_UNALLOC, Enums::STATUS_COMPLETE, Enums::STATUS_ARCHIVE))) { if ($companies) { $update['$set']['status'] = Enums::STATUS_ALLOC; } } elseif ($status == Enums::STATUS_ALLOC) { if (!$companies) { $update['$unset']['status'] = 1; } } else { $update['$set']['status'] = Enums::STATUS_COMPLETE; } $count++; $jobs->update(array('_id' => $job['_id']), $update); $values[] = array('time' => $assign_time, 'user_id' => User::current('id'), 'company_id' => max($company, 0), 'job_id' => $job['_id'], 'type' => $type); } } if ($values) { $insert = DB::insert('assign_log', array_keys($values[0])); foreach ($values as $value) { $insert->values($value); } $insert->execute(); } if ($company == -1) { Messages::save($count . ' jobs were succesfully unassigned', 'success'); } else { Messages::save($count . ' jobs were succesfully assigned to ' . Company::get($company, 'name'), 'success'); $users = DB::select('id')->from('users')->where('company_id', '=', $company)->execute()->as_array(NULL, 'id'); $message = $count . ' tickets were allocated on ' . date('d-m-Y H:i', $assign_time) . '. <a href="javascript:;" class="tickets-search-assign" data-date="' . date('d-m-Y H:i:s', $assign_time) . '">View ticket(s)</a>'; $insert = DB::insert('notifications', array('user_id', 'message')); foreach ($users as $user) { $insert->values(array($user, $message)); } $insert->execute(); } } $this->redirect('/search'); }
echo '<div class="endGPA" ' . $datestyle . '>' . date("j F Y", strtotime($session->get("date"))) . '</div>'; } else { echo '<div class="endGPA" ' . $datestyle . '>Date not agreed</div>'; } ?> </div> <div class="companyIcon"> <?php echo '<div data-orgId="' . HttpSession::currentUser()->company_id . '" data-access="' . HttpSession::currentUser()->getOrganization()->access_level . '" data-id="' . $session->id . '" class="linkedLink takeSession"><a href="">Express Interest to take this Session</a></div>'; ?> </div> <div class="proposedIcon"> <?php if (!is_null($session->get("org_id"))) { $company = Company::get($session->get("org_id")); $style = ""; if ($session->get("org_id") === HttpSession::currentUser()->company_id) { $style = 'style="color:#ed7d31 !important"'; } echo '<div class="linkedLink company-name" ' . $style . ' >' . $company->name . '</div>'; } ?> </div> </div> </div> <div class="darkGray">
if (haveViewAccess($project)) { ?> <div class="userIcon"> <div class="endGPA"><?php echo $project->get("resp_name") . ' (' . $project->get("resp_contact") . ')'; ?> </div> </div> <?php } ?> <div class="companyIcon"> <?php if (!is_null($project->get("org_id"))) { $company = Company::get($project->get("org_id")); $style = ""; if ($project->get("org_id") === HttpSession::currentUser()->company_id) { $style = 'style="color:#ed7d31 !important"'; } echo '<div class="linkedLink company-name" ' . $style . ' >' . $company->name . '</div>'; } else { echo '<div data-orgId="' . HttpSession::currentUser()->company_id . '" data-access="' . HttpSession::currentUser()->getOrganization()->access_level . '" data-id="' . $project->id . '" class="linkedLink takeSession"><a href="">Express Interest to pick the Research Work</a></div>'; } ?> </div> <div class="endGPA"> <?php $batches = $project->getBatches(); if (count($batches) > 0) {
/** * @param int $training_id * @param string $company_url_segment * @return array * @throws Exception */ public function getCompanyTraining($training_id, $company_url_segment) { if (empty($company_url_segment)) { throw new Exception("Invalid Company"); } //@todo: remove dataobjects dependencies $company = Company::get()->filter('URLSegment', $company_url_segment)->first(); $training = empty($training_id) ? null : TrainingService::get()->byID($training_id); if (!$company) { throw new Exception("Invalid Company"); } if (!$training) { //get default program $training = $company->getDefaultTraining(); } //check if program belongs to selected company $training_company = $training->Company(); if ($training_company->getIdentifier() != $company->getIdentifier()) { //if not , get default program $training = $company->getDefaultTraining(); } if (!$this->training_manager->isActive($training->getIdentifier())) { return Security::permissionFailure($this->controller, "non active training!."); } $courses = $this->training_manager->getCoursesByDate($training->getIdentifier(), DateTimeUtils::getCurrentDate()); $courses_vm = new ArrayList(); foreach ($courses as $course) { $course_dto = new CourseDTO($course->getIdentifier(), $course->getName(), $course->getDescription(), $course->getTraining()->getIdentifier(), null, null, null, $course->level()->Level, $course->isOnline(), null, null, null, null, null, $course->getOnlineLink()); $locations_dto = $this->course_repository->getLocationsByDate($course->getIdentifier(), DateTimeUtils::getCurrentDate()); $locations_vm = new ArrayList(); foreach ($locations_dto as $location_dto) { $locations_vm->push(new CourseLocationViewModel($location_dto)); } $courses_vm->push(new CourseViewModel($course_dto, $locations_vm, $course->projects())); } $res = array('Company' => $company, 'Training' => $training, 'Courses' => $courses_vm, 'Slug' => $training->getSlug()); return $res; }
public static function getByID($id) { $company = new Company(); $company->get(["id" => $id]); return $company; }
<?php require_once './global.inc.php'; verify_oauth_session_exists(); $event_id = $_POST["event_id"]; $event_details = Event::get($event_id); $spTools = new SponsorshipTools(); $sponsorship_details = $spTools->getAllSponsorshipsByEvent($event_id); $sponsorships = array(); foreach ($sponsorship_details as $sp) { $company = NULL; if ($sp->taken_by != "") { $company = Company::get($sp->taken_by); } array_push($sponsorships, array($sp, $company)); } echo json_encode(array($event_details, $sponsorships));
public function editCustCompany() { $id = Input::get('editComID'); $company = Company::find($id); $comp = Company::get(); $isAdded = FALSE; $validInput = TRUE; $regex = "/^[a-zA-Z\\'\\-\\.\\,]+( [a-zA-Z\\'\\-\\.\\,]+)*\$/"; $regexName = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/"; $regexHouse = "/[0-9a-zA-Z\\-\\s]+\$/"; $regexStreet = "/^[a-zA-Z0-9\\'\\-\\.]+( [a-zA-Z0-9\\'\\-\\.]+)*\$/"; $regexBarangay = "/^[a-zA-Z0-9\\'\\-\\.]+( [a-zA-Z0-9\\'\\-\\.]+)*\$/"; $regexCity = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/"; $regexZip = "/^[0-9]+\$/"; $regexProvince = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/"; if (!trim(Input::get('editComName')) == '' && !trim(Input::get('editConPerson')) == '' && !trim(Input::get('editCustCompanyHouseNo')) == '' && !trim(Input::get('editComEmailAddress')) == '' && !trim(Input::get('editCustCompanyStreet')) == '' && !trim(Input::get('editCustCompanyCity')) == '' && !trim(Input::get('editCel')) == '') { $validInput = TRUE; if (preg_match($regex, Input::get('editComName')) && preg_match($regexName, Input::get('editConPerson')) && preg_match($regexHouse, Input::get('editCustCompanyHouseNo')) && !!filter_var(Input::get('editComEmailAddress'), FILTER_VALIDATE_EMAIL) && preg_match($regexStreet, Input::get('editCustCompanyStreet')) && preg_match($regexCity, Input::get('editCustCompanyCity'))) { $validInput = TRUE; if (!trim(Input::get('editCustCompanyZipCode')) == '' || !trim(Input::get('editCustCompanyProvince')) == '' || !trim(Input::get('editCustCompanyBarangay')) == '') { if (preg_match($regexZip, Input::get('editCustCompanyZipCode')) || preg_match($regexProvince, Input::get('editCustCompanyProvince')) || preg_match($regexBarangay, Input::get('editCustCompanyBarangay'))) { $validInput = TRUE; } else { $validInput = FALSE; } } } else { $validInput = FALSE; } } else { $validInput = FALSE; } $count = 0; $count2 = 0; if (!($company->strCustCompanyEmailAddress == trim(Input::get('editComEmailAddress')))) { $count = DB::table('tblCustCompany')->select('tblCustCompany.strCustCompanyEmailAddress')->where('tblCustCompany.strCustCompanyEmailAddress', '=', trim(Input::get('editComEmailAddress')))->count(); } if (!($company->strCustCompanyCPNumber == trim(Input::get('editCel')))) { $count2 = DB::table('tblCustCompany')->select('tblCustCompany.strCustCompanyCPNumber')->where('tblCustCompany.strCustCompanyCPNumber', '=', trim(Input::get('editCel')))->count(); } if ($count > 0 || $count2 > 0) { $isAdded = TRUE; } else { foreach ($comp as $comp) { if (!strcasecmp($comp->strCustCompanyID, trim(Input::get('editComID'))) == 0 && (strcasecmp($comp->strCustCompanyName, trim(Input::get('editComName'))) == 0 || strcasecmp($comp->strCustContactPerson, trim(Input::get('editConPerson'))) == 0)) { $isAdded = TRUE; } } } if ($validInput) { if (!$isAdded) { $company = Company::find($id); $company->strCustCompanyName = trim(Input::get('editComName')); $company->strCustCompanyHouseNo = trim(Input::get('editCustCompanyHouseNo')); $company->strCustCompanyStreet = trim(Input::get('editCustCompanyStreet')); $company->strCustCompanyBarangay = trim(Input::get('editCustCompanyBarangay')); $company->strCustCompanyCity = trim(Input::get('editCustCompanyCity')); $company->strCustCompanyProvince = trim(Input::get('editCustCompanyProvince')); $company->strCustCompanyZipCode = trim(Input::get('editCustCompanyZipCode')); $company->strCustContactPerson = trim(Input::get('editConPerson')); $company->strCustCompanyEmailAddress = trim(Input::get('editComEmailAddress')); $company->strCustCompanyTelNumber = trim(Input::get('editPhone')); $company->strCustCompanyCPNumber = trim(Input::get('editCel')); $company->strCustCompanyCPNumberAlt = trim(Input::get('editCelAlt')); $company->strCustCompanyFaxNumber = trim(Input::get('editFax')); $company->save(); return Redirect::to('/maintenance/customerCompany?successEdit=true'); } else { return Redirect::to('/maintenance/customerCompany?success=duplicate'); } } else { return Redirect::to('/maintenance/customerCompany?input=invalid'); } }