public function Employeenotassigned($id, $elect)
 {
     $results = array();
     $emp = Employees::model()->findAllByAttributes(array('employee_department_id' => $id));
     if ($emp != NULL) {
         $i = 0;
         foreach ($emp as $emp1) {
             if (EmployeeElectiveSubjects::model()->findByAttributes(array('employee_id' => $emp1->id, 'elective_id' => $elect)) == NULL) {
                 $results[$i] = $emp1;
                 $i++;
             }
         }
     }
     return $results;
 }
 public function actionAjax_delete()
 {
     $id = $_POST['id'];
     $subject = Subjects::model()->findByAttributes(array('elective_group_id' => $id));
     $timetable = TimetableEntries::model()->deleteAllByAttributes(array('subject_id' => $subject->id));
     $examgroup = Exams::model()->deleteAllByAttributes(array('subject_id' => $subject->id));
     EmployeeElectiveSubjects::model()->deleteAllByAttributes(array('subject_id' => $subject->id));
     $subject->delete();
     $deleted = $this->loadModel($id);
     if ($deleted->delete()) {
         echo json_encode(array('success' => true));
         exit;
     } else {
         echo json_encode(array('success' => false));
         exit;
     }
 }
Exemple #3
0
        }
        ?>
    </table>
   </div>
    <?php 
    }
    echo '<br><span style="font-size:14px; font-weight:bold; color:#666;">Departments</span>&nbsp;&nbsp;';
    if (isset($_REQUEST['dep'])) {
        $sel_2 = $_REQUEST['dep'];
    } else {
        $sel_2 = '';
    }
    echo CHtml::dropDownList('dep_id', '', CHtml::listData(EmployeeDepartments::model()->findAll(), 'id', 'name'), array('prompt' => 'Select', 'id' => 'depart_id', 'onchange' => 'depname()', 'options' => array($sel_2 => array('selected' => true))));
    echo '<br>';
    if (isset($_REQUEST['dep']) and $_REQUEST['dep'] != NULL) {
        $employee = EmployeeElectiveSubjects::model()->Employeenotassigned($_REQUEST['dep'], $_REQUEST['elect']);
        //$employee_subjects = EmployeesSubjects::models()->findAll("employee_id=:x", array(':x'=>$_REQUEST['dept']));
        //echo count($employee);
        //exit;
        if (count($employee) != 0) {
            ?>
    <h3><?php 
            echo Yii::t('employees', 'Assign New:');
            ?>
</h3>
      <div class="tableinnerlist">
     <table width="80%" cellpadding="0" cellspacing="0">
     <tr>
         <th><?php 
            echo Yii::t('employees', 'Employee Name');
            ?>
                                       <div class="tt-subject">
                                         <div class="subject">';
 $set = TimetableEntries::model()->findByAttributes(array('batch_id' => $_REQUEST['id'], 'weekday_id' => $weekdays[6]['weekday'], 'class_timing_id' => $timing[$i]['id'], 'employee_id' => $employee->id));
 if (count($set) == 0) {
     $is_break = ClassTimings::model()->findByAttributes(array('id' => $timing[$i]['id'], 'is_break' => 1));
     if ($is_break != NULL) {
         echo Yii::t('teachersportal', 'Break');
     } else {
         $set = TimetableEntries::model()->findByAttributes(array('batch_id' => $_REQUEST['id'], 'weekday_id' => $weekdays[6]['weekday'], 'class_timing_id' => $timing[$i]['id'], 'employee_id' => NULL));
         $time_sub = Subjects::model()->findByAttributes(array('id' => $set->subject_id));
         if ($time_sub->elective_group_id != 0) {
             $time_elective_group = ElectiveGroups::model()->findByAttributes(array('id' => $time_sub->elective_group_id));
             $time_elective_sub = Electives::model()->findAllByAttributes(array('elective_group_id' => $time_elective_group->id));
             foreach ($time_elective_sub as $elective_sub) {
                 //echo $elective_sub->name;
                 $emp_elective_sub = EmployeeElectiveSubjects::model()->findByAttributes(array('elective_id' => $elective_sub->id, 'employee_id' => $employee->id));
                 if (count($emp_elective_sub) == 1) {
                     echo $time_elective_group->name . '<br>';
                     echo '(' . $elective_sub->name . ')<br>';
                     echo '<div class="employee">' . ucfirst($employee->first_name) . '</div>';
                 } else {
                     continue;
                 }
             }
             //echo $time_elective_group->name.'<br>';
         }
     }
 } else {
     $time_sub = Subjects::model()->findByAttributes(array('id' => $set->subject_id));
     if ($time_sub != NULL) {
         echo $time_sub->name . '<br>';
 /**
  * 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 = EmployeeElectiveSubjects::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }