Example #1
0
 /**
  * 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 static function loadModelByPid($type, $id)
 {
     if ($type == 'Employees') {
         $model = EmployeeSchedule::model()->findAllByAttributes(array('pid' => $id));
     } elseif ($type == 'Hardware') {
         $model = HardwareSchedule::model()->findAllByAttributes(array('pid' => $id));
     } elseif ($type == 'Facilities') {
         $model = FacilitySchedule::model()->findAllByAttributes(array('pid' => $id));
     } elseif ($type == 'CustomResources') {
         $model = CustomResources::model()->findAllByAttributes(array('pid' => $id));
     }
     return $model;
 }
Example #2
0
 /**
  * Updates a particular Resource-Schedule-model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $critearia = new CDbCriteria();
     $critearia->addCondition("pid = " . $id);
     $projectId = $_GET['id'];
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     //	if(isset($_POST['EmployeeSchedule0']) || isset($_POST['HardwareSchedule']) || isset($_POST['FacilitiesSchedule']) || isset($_POST['CustomResources0']))
     if ($_POST) {
         $ecounter = 0;
         $hcounter = 0;
         $fcounter = 0;
         $ccounter = 0;
         foreach ($_POST as $key => $value) {
             $type = $key;
             if ($type == 'EmployeeSchedule' . $ecounter) {
                 $resource = EmployeeSchedule::model()->findByPk((int) $value['id']);
                 $resource->attributes = $_POST[$key];
                 $ecounter++;
             } elseif ($type == 'HardwareSchedule' . $hcounter) {
                 $resource = HardwareSchedule::model()->findByPk((int) $value['id']);
                 $resource->attributes = $_POST[$key];
                 $hcounter++;
             } elseif ($type == 'FacilitiesSchedule' . $fcounter) {
                 $resource = FacilitySchedule::model()->findByPk((int) $value['id']);
                 $resource->attributes = $_POST[$key];
                 $fcounter++;
             } elseif ($type == 'CustomResources' . $ccounter) {
                 $resource = CustomResources::model()->findByPk((int) $value['id']);
                 $resource->attributes = $_POST[$key];
                 $ccounter++;
             }
             if ($value['delete']) {
                 $resource->delete();
             } else {
                 $resource->save();
             }
         }
         $this->redirect(array('project/view', 'id' => $projectId));
     }
     $this->render('update', array('employee' => EmployeeSchedule::model()->findAll($critearia), 'hardware' => HardwareSchedule::model()->findAll($critearia), 'facility' => FacilitySchedule::model()->findAll($critearia), 'customResources' => CustomResources::model()->findAll($critearia)));
 }
Example #3
0
 public function getBookableFacilityResources($start, $end, $resourceId)
 {
     $sql = '';
     $stm = 'SELECT facility_id from ' . Resources::FACILITY_SCHEDULE_DB . '  WHERE facility_id = ' . $resourceId . ' LIMIT 1';
     $inTable = Yii::app()->db->createCommand($stm)->querycolumn();
     $nonScheduledResources = FacilitySchedule::getNonScheduledResources();
     //if ($inTable == null && $nonScheduledResources ){
     if ($nonScheduledResources == 0) {
         //			$sql = 'SELECT f.id FROM '.Resources::FACILITY_DB.' f LEFT JOIN '.Resources::FACILITY_TYPES_DB.' t ON f.f_type = t.id WHERE t.id = '.$resourceId.' LIMIT 1';
         //		}
         //		else {
         $sql = 'SELECT f_type FROM ' . Resources::FACILITY_DB . ' f ';
         $sql .= 'JOIN ' . Resources::FACILITY_TYPES_DB . ' t ON f.f_type = t.id';
         $sql .= ' JOIN ' . Resources::FACILITY_SCHEDULE_DB . ' s ON s.facility_id = f.id';
         $sql .= ' WHERE (start_date NOT BETWEEN  \'' . $start . '\' AND \'' . $end . '\')';
         $sql .= ' OR (end_date NOT BETWEEN \'' . $start . '\' AND \'' . $end . '\')';
         $sql .= ' AND f_type = ' . $resourceId;
         $data = Yii::app()->db->createCommand($sql)->queryColumn();
         $nonScheduledResources = $data[0][0];
     }
     return $nonScheduledResources;
 }
Example #4
0
    echo '</div>';
    echo '<div class="row">';
    $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('name' => 'HardwareSchedule' . $counter . '[start_date]', 'model' => $emp, 'value' => $emp->start_date, 'htmlOptions' => array('size' => 18, 'class' => 'date'), 'options' => array('hourGrid' => 4, 'hourMin' => 8, 'hourMax' => 18, 'timeFormat' => 'h:m', 'changeMonth' => true, 'changeYear' => false, 'dateFormat' => 'yy-mm-dd', 'timeFormat' => 'hh:mm:ss', 'showAnim' => 'fold')));
    echo '<b> to </b>';
    $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('name' => 'HardwareSchedule' . $counter . '[end_date]', 'model' => $emp, 'value' => $emp->start_date, 'htmlOptions' => array('size' => 18, 'class' => 'date'), 'options' => array('hourGrid' => 4, 'hourMin' => 9, 'hourMax' => 18, 'timeFormat' => 'h:m', 'changeMonth' => true, 'changeYear' => false, 'dateFormat' => 'yy-mm-dd', 'timeFormat' => 'hh:mm:ss', 'showAnim' => 'fold')));
    echo '<input type="checkbox" name="HardwareSchedule' . $counter . '[delete]" value="delete" />delete';
    echo '</div>';
    $counter++;
}
?>
<h3>Facilities</h3>
<?php 
$counter = 0;
foreach ($facility as $fac) {
    echo '<div class="row"><label for="name">';
    echo FacilitySchedule::getResourceName($fac->facility_id) . '<br />';
    echo '<input type="hidden" id="FacilitiesSchedule' . $counter . '[id]" value="' . $fac->id . '" name="FacilitiesSchedule' . $counter . '[id]" /><br />';
    echo '</label>';
    echo '</div>';
    echo '<div class="row">';
    $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('name' => 'FacilitiesSchedule' . $counter . '[start_date]', 'model' => $emp, 'value' => $emp->start_date, 'htmlOptions' => array('size' => 18, 'class' => 'date'), 'options' => array('hourGrid' => 4, 'hourMin' => 8, 'hourMax' => 18, 'timeFormat' => 'h:m', 'changeMonth' => true, 'changeYear' => false, 'dateFormat' => 'yy-mm-dd', 'timeFormat' => 'hh:mm:ss', 'showAnim' => 'fold')));
    $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('name' => 'FacilitiesSchedule' . $counter . '[end_date]', 'model' => $emp, 'value' => $emp->start_date, 'htmlOptions' => array('size' => 18, 'class' => 'date'), 'options' => array('hourGrid' => 4, 'hourMin' => 9, 'hourMax' => 18, 'timeFormat' => 'h:m', 'changeMonth' => true, 'changeYear' => false, 'dateFormat' => 'yy-mm-dd', 'timeFormat' => 'hh:mm:ss', 'showAnim' => 'fold')));
    echo '<input type="checkbox" name="FacilitiesSchedule' . $counter . '[delete]" value="delete" />delete(Klappt nicht bei mehreren?)';
    echo '</div>';
    $counter++;
}
?>
<h3>Custom Resources</h3>
<?php 
$counter = 0;
foreach ($customResources as $cus) {