Exemplo n.º 1
0
 public function testToString()
 {
     $p = new Position(5, 10);
     $this->assertEquals("(5, 10)", $p->__toString());
     $p = new Position(7, 8, "/foo/bar/baz.ebnf");
     $this->assertEquals("/foo/bar/baz.ebnf (7, 8)", $p->__toString());
 }
Exemplo n.º 2
0
 public static function registerSendingRequest(Position $pos)
 {
     // update the this second count
     self::_incrementRequestsInSeconds();
     // finally update the current last position
     self::_setCurPosition($pos->getMyPositionId());
 }
Exemplo n.º 3
0
 public function has(Position $position) : bool
 {
     if ($this->columns->contains($position->column()) && $this->columns->get($position->column())->cells()->contains($position->row())) {
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Wait for your number to come up so you could send a request
  *
  * @return bool OK to send request, otherwise wait
  */
 public function okToSendRequest(Position $pos)
 {
     if (MemoryData::getNumRequestsThisSecond() <= 9 && MemoryData::getNumRequestsToday() < 100000 && ($pos->getPrevPositionId() == MemoryData::getCurrentPosition() || MemoryData::getSecondsSinceLastRequest() > 30)) {
         MemoryData::registerSendingRequest($pos);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 5
0
 /**
  * Position request
  */
 public function position($uri)
 {
     $this->load->library('navitia/Hydrate');
     $this->load->library('navitia/Coord');
     $this->load->library('navitia/Position');
     $position = new Position();
     $position->load_uri($uri);
     $data = array('api' => $position->getJSON(), 'html' => '');
     $this->load->view('json', array('json' => json_encode($data)));
 }
Exemplo n.º 6
0
 public static function get_all_position($connection)
 {
     $statement = $connection->prepare("SELECT * FROM position");
     $statement->execute();
     $result = $statement->get_result();
     $positions = array();
     while ($row = $result->fetch_assoc()) {
         $position = new Position();
         $position->set_name($row["position"]);
         array_push($positions, $position);
     }
     return $positions;
 }
Exemplo n.º 7
0
 public function add($postdata)
 {
     $data = json_decode($postdata);
     $FirstName = $data->FirstName;
     $LastName = $data->LastName;
     $DOB = $data->DOB;
     $Address1 = $data->Address1;
     $Address2 = $data->Address2;
     $City = $data->City;
     $State = $data->State;
     $PostalCode = $data->PostalCode;
     $Phone = $data->Phone;
     $HireDate = $data->HireDate;
     $PositionID = $data->PositionID;
     $CreatedDate = date("Y-m-d H:i:s");
     $Active = $data->Active == true ? 1 : 0;
     $this->FirstName = $FirstName;
     $this->LastName = $LastName;
     $this->DOB = $DOB;
     $this->Address1 = $Address1;
     $this->Address2 = $Address2;
     $this->City = $City;
     $this->State = $State;
     $this->PostalCode = $PostalCode;
     $this->Phone = $Phone;
     $this->HireDate = $HireDate;
     $this->PositionID = $PositionID;
     $this->CreatedDate = $CreatedDate;
     $this->Active = $Active;
     $insertData = $this->save();
     $this->FirstName = null;
     $this->LastName = null;
     $this->DOB = null;
     $this->Address1 = null;
     $this->Address2 = null;
     $this->City = null;
     $this->State = null;
     $this->PostalCode = null;
     $this->Phone = null;
     $this->HireDate = null;
     $this->PositionID = null;
     $this->CreatedDate = null;
     $this->Active = null;
     $returndata = new stdClass();
     $returndata->message = "Staff added successfully";
     $returndata->success = true;
     $obj = new Position($this->db);
     $Position = $obj->getById($PositionID)->LongName;
     $returndata->data = array('StaffID' => $insertData->_id, 'CreatedDate' => $CreatedDate, '_Position' => $Position);
     return $returndata;
 }
Exemplo n.º 8
0
 /**
  * Singleton Pattern
  *
  * Auto Create Object Instance.
  *
  */
 public static function getInstance()
 {
     if (null === self::$_objInstance) {
         self::$_objInstance = new Position();
     }
     return self::$_objInstance;
 }
Exemplo n.º 9
0
 public function loadModel($id)
 {
     $model = Position::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 10
0
 function testCreate()
 {
     $x = 53;
     $y = 87;
     $pos = Position::create($x, $y);
     $this->assertEquals($x, $pos->x);
     $this->assertEquals($y, $pos->y);
     $this->assertEquals("({$x}, {$y})", (string) $pos);
 }
Exemplo n.º 11
0
 public static function findDivisionLeaders($gid)
 {
     $conditions = array('position_id @' => array(1, 2), 'game_id' => $gid);
     $params = arrayToObject(Flight::aod()->from(Member::$table)->sortAsc('position_id')->sortDesc('rank_id')->where($conditions)->select()->many());
     foreach ($params as $member) {
         $position = Position::find($member->position_id);
         $member->position_desc = $position->desc;
     }
     return $params;
 }
Exemplo n.º 12
0
 public function getProcessInfo()
 {
     $data = array("name" => $this->name);
     $preProcessName = FlowProcess::model()->fetchAllPreProcessName($this->flowid, $this->processid);
     foreach ($preProcessName as $key => $value) {
         $data["pre"][$key] = $value["name"];
     }
     if (!empty($this->processto)) {
         foreach (explode(",", $this->processto) as $key => $toId) {
             $toId = intval($toId);
             if ($toId == 0) {
                 $data["next"][$key] = Ibos::lang("End");
             } else {
                 $next = FlowProcess::model()->fetchProcess($this->flowid, $toId);
                 $data["next"][$key] = $next["name"];
             }
             if (isset($next) && !empty($next["processin"])) {
                 $data["prcsout"][$key]["name"] = $next["name"];
                 $data["prcsout"][$key]["con"] = $next["processin"];
             }
         }
     }
     if (!empty($this->processitem)) {
         $itemPart = explode(",", $this->processitem);
         $data["processitem"] = $this->processitem;
         $data["itemcount"] = count($itemPart);
     } else {
         $data["processitem"] = "";
         $data["itemcount"] = 0;
     }
     if (!empty($this->hiddenitem)) {
         $itemPart = explode(",", $this->hiddenitem);
         $data["hiddenitem"] = $this->hiddenitem;
         $data["hiddencount"] = count($itemPart);
     } else {
         $data["hiddenitem"] = "";
         $data["hiddencount"] = 0;
     }
     if (!empty($this->uid)) {
         $data["user"] = User::model()->fetchRealnamesByUids($this->uid);
     } else {
         $data["user"] = "";
     }
     if (!empty($this->deptid)) {
         $data["dept"] = Department::model()->fetchDeptNameByDeptId($this->deptid);
     } else {
         $data["dept"] = "";
     }
     if (!empty($this->positionid)) {
         $data["position"] = Position::model()->fetchPosNameByPosId($this->positionid);
     } else {
         $data["position"] = "";
     }
     return $data;
 }
Exemplo n.º 13
0
 /**
  * @param Movement $move
  * @return Position
  * return Posizione di Move.
  */
 public function calculateNewPoint(Movement $move)
 {
     $destination = new Position($this->x, $this->y);
     switch ($move->getDirection()) {
         case Movement::NORTH:
             $destination->setY($destination->getY() + $move->getSpeed());
             break;
         case Movement::SOUTH:
             $destination->setY($destination->getY() - $move->getSpeed());
             break;
         case Movement::WEST:
             $destination->setX($destination->getX() - $move->getSpeed());
             break;
         case Movement::EAST:
             $destination->setX($destination->getX() + $move->getSpeed());
             break;
         default:
             throw new \RuntimeException('errore direzione');
     }
     return $destination;
 }
 /**
  * 首页.
  * 
  * @version 0.1.0 by GenialX
  * @since   0.0.1
  * 
  * @author 水木清华 <*****@*****.**>
  * @author GenialX
  */
 public function index()
 {
     $this->_common();
     $this->_header();
     $this->_sider();
     $this->_footer();
     /** 获取最新职位 **/
     $data = $this->get('data') ? $this->get('data') : array();
     $data['lastPositions'] = Position::getLastPositions();
     $this->assign("data", $data);
     $this->display();
 }
Exemplo n.º 15
0
 private static function loadItems($department_id)
 {
     self::$_items = array();
     if ($department_id <= 0) {
         $models = self::model()->findAll();
     } else {
         $models = self::model()->with(array('department' => array('select' => false, 'joinType' => 'INNER JOIN', 'condition' => '`department_id`="' . $department_id . '"')))->findAll();
     }
     //var_dump($models);
     foreach ($models as $model) {
         self::$_items[$model->id] = $model->name;
     }
 }
 protected function gavno()
 {
     $position = [];
     $list = \Schedule::model()->findAllBySql('select * from spbp_listner_schedule a
             join spbp_listner_position b on a.position_id = b.id
             join spbp_form_form c on b.form_id = c.id
             where a.number = c.number AND a.end_time < now() AND b.status = 1');
     foreach ($list as $value) {
         $a = \Position::model()->findByPk($value->position_id);
         array_push($position, $a);
     }
     return $position;
 }
 /**
  * @covers ::getByArea
  */
 public function testGetByArea()
 {
     $position = (object) array('positionId' => 1, 'positionName' => 'MY POSITION', 'positionDescription' => 'THIS IS A COOL JOB', 'employeeArea' => 2, 'deleted' => 0, 'guid' => null);
     $position2 = (object) array('positionId' => 2, 'positionName' => 'MY POSITION', 'positionDescription' => 'THIS IS A COOL JOB', 'employeeArea' => 2, 'deleted' => 0, 'guid' => null);
     $accessor = new Position();
     $model = new Position();
     $model->save($position);
     $model2 = new Position();
     $model2->save($position2);
     $position = $accessor->getByArea(2);
     $this->assertEquals(2, count($position));
     // Clean up
     $host = getenv('DBHOST');
     $user = getenv('DBUSER');
     $pass = getenv('DBPASS');
     $db = getenv('DBNAME');
     $connectStr = "mysql:dbname=" . $db . ";host=" . $host . ";port=3306";
     $options = array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ);
     $pdo = new \PDO($connectStr, $user, $pass, $options);
     $stmt = $pdo->prepare("DELETE FROM positions");
     $stmt->execute();
 }
Exemplo n.º 18
0
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $web = new sfWebBrowser();
     $latest = Doctrine::getTable('Position')->createQuery('p')->limit(1)->orderBy('p.timestamp DESC')->fetchOne();
     $this->logSection($this->namespace, 'Getting latest instamapper positions');
     $instamapper = $web->get('http://www.instamapper.com/api?action=getPositions&key=' . sfConfig::get('app_instamapper_api_key') . '&num=1000' . ($latest instanceof Position ? '&from_ts=' . $latest->getTimestamp() : '') . '&format=json');
     try {
         if (!$instamapper->responseIsError()) {
             $json = json_decode($instamapper->getResponseText());
             foreach ($json->positions as $gps) {
                 if (!$latest instanceof Position || $gps->timestamp >= $latest->getTimestamp()) {
                     $position = new Position();
                     $position->setDeviceKey($gps->device_key);
                     $position->setDeviceLabel($gps->device_label);
                     $position->setTimestamp($gps->timestamp);
                     $position->setLatitude($gps->latitude);
                     $position->setLongitude($gps->longitude);
                     $position->setAltitude($gps->altitude);
                     $position->setSpeed($gps->speed);
                     $position->setHeading($gps->heading);
                     $position->save();
                     echo '.';
                     $this->new++;
                 }
             }
         } else {
             // Error response (eg. 404, 500, etc)
         }
     } catch (Exception $e) {
         // Adapter error (eg. Host not found)
     }
     echo "\n";
     $this->logSection($this->namespace, 'Done: ' . $this->new . ' added.');
 }
 public static function _edit()
 {
     $user = User::find(intval($_SESSION['userid']));
     $member = Member::findByMemberId($_POST['member_id']);
     $platoons = Platoon::find_all($member->game_id);
     // if user role lower than plt ld, show only own platoon's squads
     $platoon_id = $user->role >= 2 && !User::isDev() ? $member->platoon_id : false;
     $squads = Squad::findAll($member->game_id, $platoon_id);
     $positionsArray = Position::find_all();
     $rolesArray = Role::find_all();
     $memberGames = MemberGame::get($member->id);
     if (User::isUser($member->id)) {
         $userInfo = User::findByMemberId($member->id);
     } else {
         $userInfo = null;
     }
     Flight::render('modals/view_member', array('user' => $user, 'member' => $member, 'userInfo' => $userInfo, 'platoons' => $platoons, 'memberGames' => $memberGames, 'squads' => $squads, 'positionsArray' => $positionsArray, 'rolesArray' => $rolesArray));
 }
Exemplo n.º 20
0
 public function fetchAllListByFlowId($flowId)
 {
     $list = $this->fetchAllByFlowId($flowId);
     foreach ($list as &$per) {
         $per["userName"] = !empty($per["uid"]) ? User::model()->fetchRealnamesByUids($per["uid"]) : "";
         if (!empty($per["deptid"])) {
             if ($per["deptid"] == "alldept") {
                 $per["deptName"] = "全体部门";
             } else {
                 $per["deptName"] = Department::model()->fetchDeptNameByDeptId($per["deptid"]);
             }
         } else {
             $per["deptName"] = "";
         }
         $per["posName"] = !empty($per["positionid"]) ? Position::model()->fetchPosNameByPosId($per["positionid"]) : "";
         $per["typeName"] = Ibos::lang($this->_typeLangMap[$per["type"]], "workflow.default");
         if (array_key_exists($per["scope"], $this->_scopeLangMap)) {
             $per["scopeName"] = Ibos::lang($this->_scopeLangMap[$per["scope"]], "workflow.default");
         } else {
             $per["scopeName"] = Department::model()->fetchDeptNameByDeptId($per["scope"]);
         }
     }
     return $list;
 }
Exemplo n.º 21
0
// Part 1 //////////////////////////////////////////////////////////////////////
// Initialize position
$current = Position::origin();
$positions = [(string) $current];
// Loop through each direction instruction character
foreach ($directions as $direction) {
    $current->moveDirection($direction);
    $positions[] = (string) $current;
}
$counts = array_count_values($positions);
$houses = count($counts);
print "Houses that got at least 1 present: {$houses}.";
// Part 2 //////////////////////////////////////////////////////////////////////
// Initialize position
$santa = Position::origin();
$santaPositions = [(string) $santa];
$robo = Position::origin();
$roboPositions = [(string) $robo];
// Loop through each direction instruction character
foreach ($directions as $i => $direction) {
    if ($i % 2 == 0) {
        $robo->moveDirection($direction);
        $roboPositions[] = (string) $robo;
    } else {
        $santa->moveDirection($direction);
        $santaPositions[] = (string) $santa;
    }
}
$counts = array_count_values(array_merge($santaPositions, $roboPositions));
$houses = count($counts);
print "Houses that got at least 1 present: {$houses}.";
 function livecdcreateAction()
 {
     if (!defined("NOTIF_OFF")) {
         //Lets keep liveCD screens private for now
         define("NOTIF_OFF", 1);
     }
     $this->setTitle('Screen Creation');
     $screen = new Screen();
     //Defaults for live cds
     /*
     $default_template = 22;
     $default_subscriptions[73][] = 0;
     $default_subscriptions[74][] = 1;
     $default_subscriptions[74][] = 30;
     $default_subscriptions[75][] = 8;
     $default_subscriptions[75][] = 11;
     */
     if (!isset($default_template) || !isset($default_subscriptions) || !is_array($default_subscriptions)) {
         $this->flash('Live CD support has not been configured yet.  Please contact an administrator.', 'error');
         redirect_to(ADMIN_URL);
     }
     if ($screen->create_screen($_POST[screen][name], $_POST[screen][group], $_POST[screen][location], $_POST[screen][mac_inhex], $_POST[screen][width], $_POST[screen][height], $default_template, 1)) {
         //Now setup some sample subscriptions
         foreach ($default_subscriptions as $field_id => $subscriptions) {
             foreach ($subscriptions as $feed_id) {
                 $pos = new Position();
                 $pos->create_position($screen->id, $feed_id, $field_id);
             }
         }
         redirect_to(ROOT_URL . '/?mac=' . $_POST[screen][mac_inhex] . '&w=' . $_POST[screen][width] . '&h=' . $_POST[screen][height] . '&livecd=1');
     } else {
         $this->flash('The screen creation failed. ' . 'Please check all fields and try again; contact an administrator if all else fails.', 'error');
         redirect_to(ADMIN_URL . '/screens/livecd?mac=' . $_POST[screen][mac_inhex] . '&w=' . $_POST[screen][width] . '&h=' . $_POST[screen][height] . '&livecd=1');
     }
 }
 public function test_has_one_with_order()
 {
     Employee::$has_one[0]['order'] = 'title';
     $employee = $this->get_relationship();
     $this->assert_default_has_one($employee);
     $this->assert_sql_has('ORDER BY title', Position::table()->last_sql);
 }
Exemplo n.º 24
0
 /**
  * User edit form
  * 
  * @param int $id
  * @return \View
  */
 public function getEdit($id = false)
 {
     if (!$id) {
         return App::abort(404);
     }
     $item = User::find($id);
     if (!$item) {
         return App::abort(404);
     }
     Orchestra\Asset::add("jquery-ui", "assets/js/ui/js/jquery-ui-1.10.3.custom.min.js");
     Orchestra\Asset::add("jquery-ui", "assets/js/ui/css/hot-sneaks/jquery-ui-1.10.3.custom.min.css");
     Orchestra\Asset::add("mask", "assets/js/mask.js");
     $positions = Position::select(["positions.id", "positions.name", "departments.name as department_name"])->leftjoin("departments", "departments.id", "=", "positions.department_id")->orderBy("departments.name")->orderBy("positions.name")->get();
     $content = View::make("users/edit", ["positions" => $positions, "item" => $item]);
     return View::make("common/tpl", array("template" => $content));
 }
Exemplo n.º 25
0
	function add_feed($feed_id_in){
		if($this->screen_set){
         if(is_array($this->screen_pos))
			foreach($this->screen_pos as $pos){
				if($pos->feed_id == $feed_id_in){
					return true; //The mapping already exists.  Someone cannot see that, maybe they are using an iphone and the screen is tiny. dumb iphone
				}
			}
			$new_pos = new Position();
			if($new_pos->create_position($this->screen_id, $feed_id_in, $this->id)){
				$this->screen_pos[] = $new_pos;
				$notify = new Notification();
				$notify->notify('screen', $this->screen_id, 'feed', $feed_id_in, 'subscribe');	
                                return true;
			} else {
				return false;
			}
		} else {
			return false; //No screen = no fun :-(
		}
	}
Exemplo n.º 26
0
 /**
  * function name : delete
  * edit data Position
  * get
  */
 public function delete($id)
 {
     if (Auth::check()) {
         $result = Position::where('position_id', $id)->delete();
         if ($result) {
             return Redirect::to('admin/positions')->with('success_message', 'ลบข้อมูลเรียบร้อยแล้ว');
         } else {
             return Redirect::to('admin/positions')->with('error_message', 'ไม่สามารถลบข้อมูลได้ กรุณาแจ้งผู้ดูแลระบบ');
         }
     } else {
         return View::make('users.index');
     }
 }
Exemplo n.º 27
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if (XUtils::method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif (XUtils::method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
         is_array($ids) && ($ids = implode(',', $ids));
     } else {
         XUtils::message('errorBack', '只支持POST,GET数据');
     }
     empty($ids) && XUtils::message('error', '未选择记录');
     switch ($command) {
         case 'delete':
             parent::_acl('position_delete');
             $cityModel = new Position();
             $cityModel->deleteAll('id IN(' . $ids . ')');
             AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids));
             parent::_delete(new Position(), $ids, array('index'));
             break;
         default:
             throw new CHttpException(404, '错误的操作类型:' . $command);
             break;
     }
 }
Exemplo n.º 28
0
 *   @license  https://github.com/yupe/yupe/blob/master/LICENSE BSD
 *   @link     http://yupe.ru
 **/
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', ['action' => Yii::app()->createUrl($this->route), 'method' => 'get', 'type' => 'vertical', 'htmlOptions' => ['class' => 'well']]);
?>

<fieldset>
    <div class="row">
        <div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'id', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('id'), 'data-content' => $model->getAttributeDescription('id')]]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->dropDownListGroup($model, 'position_id', ['widgetOptions' => ['data' => CHtml::listData(Position::model()->findAll(), 'id', 'id')]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'number', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('number'), 'data-content' => $model->getAttributeDescription('number')]]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'start_time', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('start_time'), 'data-content' => $model->getAttributeDescription('start_time')]]]);
?>
        </div>
		<div class="col-sm-3">
            <?php 
echo $form->textFieldGroup($model, 'end_time', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('end_time'), 'data-content' => $model->getAttributeDescription('end_time')]]]);
Exemplo n.º 29
0
    <?php 
if (!isset($data['params'])) {
    $positions = $data['positions'];
    $objPosition = $data['objPosition'];
} else {
    $objPosition = new Position();
    $positions = $objPosition->getAllPositions();
}
?>
        
        
        <h2>Catergories</h2>    
        <table cellpadding="0" cellspacing="0" border="0" class="tbl_repeat" id="categoriesTable" style="margin-bottom:0px;" data-object="position" >
            <tr>
                <th style="border-right:dashed 1px #222;width:120px;">Name</th>
                <th style="width:50px;">EXCO</th>
                <th style="width:50px;">Project</th>
                <th>Action</th>
            </tr>
        <?php 
foreach ($positions as $position) {
    $disabledEXCO = '';
    $disabledProject = '';
    $disabled = '';
    if ($position['exco'] == '1') {
        $disabledEXCO = $objPosition->checkPositionExistsInInvolvements($position['id'], true);
    }
    if ($position['project'] == '1') {
        $disabledProject = $objPosition->checkPositionExistsInInvolvements($position['id']);
    }
    if (!empty($disabledEXCO) || !empty($disabledProject)) {
 /**
  * Remove the specified resource from storage.
  * DELETE /position/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $position = Position::find($id)->delete();
     if (is_null($position)) {
         $class = 'error';
         $message = 'Record does not exist.';
     } else {
         $class = 'success';
         $message = 'Record successfully deleted.';
     }
     return Redirect::route('designated-position.index')->with('class', $class)->with('message', $message);
 }