/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Transportation(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Transportation'])) { $trans = Transportation::model()->findByAttributes(array('student_id' => $_POST['student_id'])); $model->attributes = $_POST['Transportation']; $model->student_id = $_POST['student_id']; if ($trans != NULL and $_POST['student_id']) { $this->redirect(array('error')); } else { if (isset($_POST['student_id']) and $_POST['student_id'] != NULL) { $allot = Allotment::model()->findByAttributes(array('student_id' => $_POST['student_id'])); if ($allot->student_id == $_POST['student_id']) { $this->redirect(array('warning', 'transportation' => $_POST['Transportation'], 'student_id' => $_POST['student_id'])); } } if (isset($_POST['Transportation']['stop_id']) and $_POST['Transportation']['stop_id'] != NULL) { $stop = StopDetails::model()->findByAttributes(array('id' => $_POST['Transportation']['stop_id'])); $route = RouteDetails::model()->findByAttributes(array('id' => $stop->route_id)); $vehicle = VehicleDetails::model()->findByAttributes(array('id' => $route->vehicle_id)); $connection = Yii::app()->db; $sql = "SELECT t2.id FROM transportation AS t2 JOIN stop_details AS t1 WHERE t2.stop_id = t1.id AND t1.route_id= " . $stop->route_id; $command = $connection->createCommand($sql); $stops = $command->queryAll(); } if ($vehicle->maximum_capacity >= count($stops)) { if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } else { Yii::app()->user->setFlash('errorMessage', UserModule::t("No seat available in the vehicle!")); $this->redirect(array('create')); } } } $this->render('create', array('model' => $model)); }
public function actionAssign() { $model = new DriverDetails(); if (isset($_POST['search'])) { if (isset($_POST['driver_id']) and $_POST['driver_id'] != NULL) { $drive = DriverDetails::model()->findByAttributes(array('id' => $_POST['driver_id'])); if (isset($_POST['vehicle_id']) and $_POST['vehicle_id'] != NULL) { $vehicle = VehicleDetails::model()->findByAttributes(array('id' => $_POST['vehicle_id'])); if ($vehicle != NULL) { $vehicle->status = 'C'; $vehicle->save(); } $drive->vehicle_id = $_POST['vehicle_id']; $drive->status = 'C'; $drive->save(); } $this->render('assign', array('model' => $model, 'id' => $drive->id)); } else { $this->render('error', array('model' => $model)); } } else { $this->render('assign', array('model' => $model)); } }
<tr> <td width="247" valign="top"> <?php $this->renderPartial('/transportation/trans_left'); ?> </td> <td valign="top"> <div class="cont_right"> <h1> <?php echo Yii::t('transport', 'FuelConsumption'); ?> </h1> <?php $driver = FuelConsumption::model()->findByAttributes(array('id' => $_REQUEST['id'])); $vehicle = VehicleDetails::model()->findByAttributes(array('id' => $driver->vehicle_id)); ?> <div class="pdtab_Con"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr class="pdtab-h"> <td align="center"> <?php echo Yii::t('transport', 'Vehicle Code'); ?> </td> <td align="center"> <?php echo Yii::t('transport', 'Fuel Consumed'); ?> </td>
<td valign="top"> <div class="cont_right"> <h1><?php echo Yii::t('transport', 'Vehicle Details'); ?> </h1> <div class="edit_bttns" style="top:20px; right:20px;"> <ul> <li> <?php echo CHtml::link('<span>' . Yii::t('transport', 'Enter Vehicle Details') . '</span>', array('/transport/vehicleDetails/create'), array('class' => 'addbttn last ')); ?> </li> </ul> </div> <?php $vehicle = VehicleDetails::model()->findAll('status=:x AND is_deleted=:y', array(':x' => 'C', ':y' => 0)); ?> <div class="pdtab_Con"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr class="pdtab-h"> <td align="center"><?php echo Yii::t('transport', 'Vehicle No.'); ?> </td> <td align="center"><?php echo Yii::t('transport', 'no_of_seats'); ?> </td> <td align="center"><?php echo Yii::t('transport', 'maximum_capacity'); ?>
/** * 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 = VehicleDetails::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<td> </td> <td> </td> </tr> <tr> <td> <?php echo $form->labelEx($model, Yii::t('transport', 'vehicle_id')); ?> </td> <td> </td> <td> <?php echo $form->dropDownList($model, 'vehicle_id', CHtml::listData(VehicleDetails::model()->findAll('status=:x', array(':x' => 'C')), 'id', 'vehicle_code'), array('prompt' => 'Select')); ?> <?php echo $form->error($model, 'vehicle_id'); ?> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr>
<?php $this->breadcrumbs = array('Route Details' => array('/transport'), 'RouteDetails'); $form = $this->beginWidget('CActiveForm', array('id' => 'vacate-form', 'enableAjaxValidation' => false)); echo '<strong>' . CHtml::label(Yii::t('transport', 'Select Route'), '') . '</strong>'; //echo CHtml::dropDownList('routeid','',array(),array('prompt'=>'Select','id'=>'stopid')); echo CHtml::dropDownList('routeid', '', CHtml::listData(RouteDetails::model()->findAll(), 'id', 'route_name'), array('prompt' => 'Select', 'id' => 'route_id', 'submit' => array('RouteDetails/routedetails'))); if (isset($routeid)) { if ($routeid == NULL) { echo '<div align="center">' . Yii::t('transport', 'Sorry!! No data available now.') . '</div>'; } else { $routedetails = RouteDetails::model()->findByAttributes(array('id' => $routeid)); $vehicle = VehicleDetails::model()->findByAttributes(array('id' => $routedetails->vehicle_id)); $stop = StopDetails::model()->findAllByAttributes(array('route_id' => $routeid)); if ($stop == NULL) { echo '<div align="center"><strong>' . Yii::t('transport', 'Sorry!! No data available now.') . '</strong></div>'; } else { ?> <table width="22%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php echo Yii::t('transport', 'Route'); ?> </td> <td><?php echo Yii::t('transport', 'Stop'); ?> </td> <td><?php echo Yii::t('transport', 'Vehicle ID');
<tr> <td> <?php echo $form->labelEx($model, Yii::t('transport', 'Select Vehicle'), array('style' => 'float:left')); ?> <span class="required">*</span> </td> <td> </td> <td> <?php $criteria = new CDbCriteria(); $criteria->compare('is_deleted', 0); ?> <?php echo $form->dropDownList($model, 'vehicle_id', CHtml::listData(VehicleDetails::model()->findAll($criteria), 'id', 'vehicle_code'), array('prompt' => 'Select')); ?> <?php echo $form->error($model, 'vehicle_id'); ?> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr>
<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="247" valign="top"> <?php $this->renderPartial('/transportation/trans_left'); ?> </td> <td valign="top"> <div class="cont_right"> <h1> <?php echo Yii::t('transport', 'Vehicle Details'); ?> </h1> <?php $driver = VehicleDetails::model()->findByAttributes(array('id' => $_REQUEST['id'])); ?> <div class="pdtab_Con" > <table width="80%" border="0" cellspacing="0" cellpadding="0" style="text-align:center;"> <tr class="pdtab-h" style="font-weight:bold;"> <td> <?php echo Yii::t('transport', 'Vehicle No'); ?> </td> <td> <?php echo Yii::t('transport', 'Vehicle Code'); ?> </td> <td>