public function ReturnToBase() { if ($this->DeleteFromDatabase() > 0) { $homeMission = Transportation::FromOtherMission($this); if ($homeMission->AddToDatabase() > 0) { return true; } } // TODO: error here? return false; }
<td align="center"> <?php echo Yii::t('transport', 'Action'); ?> </td> </tr> <tr> <?php $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; $total = Transportation::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(Yii::app()->params['listPerPage']); $pages->applyLimit($criteria); // the trick is here! $route = Transportation::model()->findAll($criteria); $page_size = Yii::app()->params['listPerPage']; ?> <?php //$route=Transportation::model()->findAll(); if ($route) { foreach ($route as $route1) { $student = Students::model()->findByAttributes(array('id' => $route1->student_id)); $stop = StopDetails::model()->findByAttributes(array('id' => $route1->stop_id)); $route = RouteDetails::model()->findByAttributes(array('id' => $stop->route_id)); ?> <td align="center"> <?php echo $student->last_name . ' ' . $student->first_name;
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Transportation::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
font-weight:bold; text-align:center; } .tableinnerlist th{ border-right:1px #b9c7d0 solid; border-bottom:1px #b9c7d0 solid; padding:4px 10px; font-size:12px; font-weight:bold; text-align:center; } </style> <?php $list = Transportation::model()->findByAttributes(array('student_id' => $studentid, 'is_paid' => 1)); $posts = Students::model()->findByAttributes(array('id' => $studentid)); $stop = StopDetails::model()->findByAttributes(array('id' => $list->stop_id)); $route = RouteDetails::model()->findByAttributes(array('id' => $stop->route_id)); $batch = Batches::model()->findByAttributes(array('id' => $posts->batch_id)); $course = Courses::model()->findByAttributes(array('id' => $batch->course_id)); $currency = Configurations::model()->findByPk(5); ?> <table width="600" border="1" bgcolor="#f9feff"> <tr> <td> <div style="padding:10px 20px;"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150"> <?php
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Registration(); $model_1 = new Room(); //$err_msg = ''; $err_flag = 0; $err_msg = Yii::t('hostel', 'Please fix the following errors.') . '<br/>'; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Registration'])) { $roles = Rights::getAssignedRoles(Yii::app()->user->Id); // check for single role foreach ($roles as $role) { if (sizeof($roles) == 1 and $role->name == 'student') { $request = new Roomrequest(); $model->student_id = $_POST['Registration']['student_id']; $model->food_preference = $_POST['Registration']['food_preference']; $model->status = 'C'; $request->student_id = $_POST['Registration']['student_id']; $request->status = 'C'; $request->save(); $model->save(); $this->redirect(array('/hostel/registration/create')); } else { if ($_POST['hostel'] == NULL) { $err_flag = 1; $err_msg = $err_msg . '- ' . Yii::t('hostel', 'Hostel cannot be blank') . '<br/>'; } if ($_POST['floor'] == NULL) { $err_flag = 1; $err_msg = $err_msg . '- ' . Yii::t('hostel', 'Floor cannot be blank') . '<br/>'; } if ($_POST['student_id'] == NULL) { $err_flag = 1; $err_msg = $err_msg . '- ' . Yii::t('hostel', 'Student cannot be blank') . '<br/>'; } if ($_POST['Registration']['food_preference'] == NULL) { $err_flag = 1; $err_msg = $err_msg . '- ' . Yii::t('hostel', 'Food Preference cannot be blank') . '<br/>'; } if ($err_flag == 0) { $allot_erre = Allotment::model()->findByAttributes(array('student_id' => $_POST['student_id'], 'status' => 'S')); $hostel_reg = Registration::model()->findByAttributes(array('student_id' => $_POST['student_id'], 'status' => 'S')); $model->attributes = $_POST['Registration']; $model->student_id = $_POST['student_id']; if ($allot_erre != NULL and $hostel_reg != NULL) { $this->redirect(array('error', 'student_id' => $_POST['student_id'])); } $trans = Transportation::model()->findByAttributes(array('student_id' => $_POST['student_id'])); if ($trans->student_id != NULL) { if ($trans->student_id == $_POST['student_id']) { $this->redirect(array('warning', 'registration' => $_POST['Registration'], 'student_id' => $_POST['student_id'], 'floor_id' => $_POST['floor'], 'hostel' => $_POST['hostel'])); } } $register = Registration::model()->findByAttributes(array('student_id' => $_POST['student_id'])); //var_dump($register->attributes);exit; if ($register != NULL) { $request = Roomrequest::model()->findByAttributes(array('student_id' => $register->student_id, 'status' => 'C')); if ($request != NULL) { $request->status = 'S'; $request->save(); } $register->status = 'S'; $register->save(); } else { $model->food_preference = $_POST['Registration']['food_preference']; $model->student_id = $_POST['student_id']; $model->status = 'S'; } if ($model->save()) { //$bed_info=Allotment::model()->findAll('status=:x AND student_id=:y',array(':x'=>'C',':y'=>NULL)); $bed_info = Allotment::model()->findByAttributes(array('student_id' => NULL, 'status' => 'C')); //var_dump($bed_info->attributes);exit; if ($bed_info == NULL) { $this->redirect(array('/hostel/allotment/roominfo/')); } else { $this->redirect(array('/hostel/room/roomlist', 'id' => $model->student_id, 'floor_id' => $_POST['floor'])); } } } else { Yii::app()->user->setFlash('errorMessage', $err_msg); } } } } $this->render('create', array('model' => $model)); }
public static function FromOtherMission(Mission $otherMission) { return Transportation::NewTransportation($otherMission->Fleet(), $otherMission->Fleet()->OriginalColony()); }
private function ExecuteTransport(array $row, Colony $c = NULL) { $transport = Transportation::FromDatabase($row, $c); $transport->Arrive(); }
echo "<br/>"; echo "<br/>"; echo "Current colony:"; Helper::var_dump_pre($user->CurrentColony()->ID()); $units = array("light_fighter" => 10, "small_cargo_ship" => 20, "cruiser" => 10); $extrafleet = ShipFleet::FromList($units, $user->CurrentColony(), 0); //Helper::var_dump_pre( $user->CurrentColony()->Fleet() ); echo "Adding some extra units to original fleet: "; $user->CurrentColony()->Fleet()->AddToFleet($extrafleet); $user->CurrentColony()->Fleet()->UpdateDatabase(); $t_units = array("light_fighter" => 5, "small_cargo_ship" => 5, "cruiser" => 3); $t_fleet = ShipFleet::FromList($t_units, $user->CurrentColony(), 0); echo "Splitting up some units from the original fleet: "; $fleets = $user->CurrentColony()->Fleet()->SplitFleet($t_fleet); // Let's send a part of the fleet on a transport mission $transport = Transportation::NewTransportation($fleets["new_fleet"], $colony); //$transport->AddToDatabase(); $transport->Validate(); $transport->AddToDatabase(); //$user->CurrentColony()->Fleet()->DeductFromFleet( $extrafleet ); //Helper::var_dump_pre( $user->CurrentColony()->Fleet() ); //Helper::var_dump_pre( $user->Officers() ); //Helper::var_dump_pre( $user->CurrentColony()->BuildingUnits() ); echo memory_get_peak_usage() / 1024; /*$user->Technologies()->ChangeTechnology( "espionage_technology", 5 ); $changes = $user->Technologies()->Changes(); $techs = $user->Technologies()->Members(); Helper::var_dump_pre( "espionage_technology" );