Exemple #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;
 }
Exemple #2
0
 public static function findAvailableEmployeeResource($resourceDb, $start, $end, $name)
 {
     //CHECK WETHER THERE IS A RESOURCE OF TYPE $type LEFT (COUNT $booked AGAINST $available???
     // NEEDED:
     //  - CHECK WETHER EMPLOYEE IS $booked FOR $date
     //  -ASSIGN RESOURCE_ID IF POSSIBLE
     $id = EmployeeSchedule::getResourceId($name, $resourceDb);
     if (EmployeeSchedule::isEmployeeBookable($start, $end, $id) > 0) {
         $id = 0;
         $error = Yii::app()->clientScript;
         $error->registerScript('error', 'alert("Employee ' . $name . ' is not available!");', CClientScript::POS_READY);
     }
     return $id;
 }
 /**
  * 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)));
 }
Exemple #4
0
<h1>Update Resources <?php 
echo $model->project->name;
?>
</h1>
<div class="form">
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'project-form', 'enableAjaxValidation' => false));
?>
<h3>Staff</h3>

<?php 
$counter = 0;
foreach ($employee as $emp) {
    echo '<div class="row"><label for="name">';
    echo EmployeeSchedule::getResourceName($emp->employee_id, Resources::EMPLOYEE_DB);
    echo '<input type="hidden" id="EmployeeSchedule' . $counter . '[id]" value="' . $emp->id . '" name="EmployeeSchedule' . $counter . '[id]" /><br />';
    echo '</label>';
    echo '</div>';
    echo '<div class="row">';
    $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('name' => 'EmployeeSchedule' . $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' => 'EmployeeSchedule' . $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="EmployeeSchedule' . $counter . '[delete]" value="delete" />delete';
    echo '</div>';
    echo '<br />';
    $counter++;
}
?>
<h3>Hardware</h3>
<?php