Пример #1
0
 function refreshRecords($materia, $plan, $anio, $cuat)
 {
     /*
             Now to your question. I would create a function in the UsersRoles model named something like refreshRoles($user, $roles). Where $user is the user id you are selecting roles for, and $roles is an array of roles that should be set. The function would retrieve the list of Roles by id_users, and compare it to $roles, deleting roles that are missing from $roles, and adding roles that are missing from the UsersRoles table.
     */
     /*$userRoles = $this->findAllByAttribute(array('id_users' => $user));
           foreach ($userRoles as $userRole) {
           if (!in_array($userRole->id_roles, $roles)) {
           $userRole->delete();
           }
           else {
           $key = array_search($userRole->id_roles, $roles));
           unset($roles[$key]);
       }*/
     $model = new MateriaPlan();
     $model->Materia_id = $materia;
     $model->Plan_id = $plan;
     $model->anio = $anio;
     $model->cuatrimestre = $cuat;
     $model->save(false);
 }
 public function actionUpdate($id)
 {
     $this->pageTitle = 'Plan - Modificar';
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Plan'])) {
         MateriaPlan::model()->deleteAll('Plan_id =' . $id);
         $id = $_POST['Plan']['anioPlan'] . $_POST['Plan']['Carrera_id'];
         $model->attributes = $_POST['Plan'];
         $model->id = $id;
         $resultado = $_POST['result'];
         $materias = $this->parseString($resultado);
         $this->agregarMaterias($materias, $id);
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('update', array('model' => $model));
 }
Пример #3
0
          <tr class="tg-even">
            <td class="anio" colspan="2">5º Año</td>
          </tr>
          <tr>
            <td id="c9" class="drop"  ondrop="dropMateria(this, event)" ondragenter="return false" ondragover="return false"></td>
            <td id="c10" class="drop"  ondrop="dropMateria(this, event)" ondragenter="return false" ondragover="return false"></td>
          </tr>
        </table>
    </div>
</div>

<?php 
//Arreglo que luego será convertido a un array js
$arregloMaterias = array();
//Obtengo todas las materias con año y cuatrimestre de un plan dado y armo un array asociativo con clave= codigo materia valor=id del cuatrimestre
$array_php = MateriaPlan::model()->findAll(array("condition" => "Plan_id =  {$model->id}"));
foreach ($array_php as $key) {
    $materiaCodigo = $key->Materia_id;
    $spanId = $this->getTableId($key->anio, $key->cuatrimestre);
    $arregloMaterias[$materiaCodigo] = $spanId;
}
?>




<script type="text/javascript">
function fillMateriasOnTable() {

 var arreglo = new Array();
 public function actionRefreshExamsEvolution()
 {
     $anios = array_values(json_decode(stripslashes($_POST['anios'])));
     $cuats = array_values(json_decode(stripslashes($_POST['cuatrimestres'])));
     $cuats_unique = array_unique($cuats);
     $this->createDaysArray();
     $utils = new Utils();
     $planes = Plan::model()->findAll(array('order' => 'anioPlan'));
     $resultados = array();
     foreach ($planes as $key) {
         //Por cada id de plan se obtienen todas las materias del mismo
         $criteriaPlanes = new CDbCriteria();
         $criteriaPlanes->select = 't.materia_id';
         $criteriaPlanes->condition = "plan_id == " . $key->id;
         $criteriaPlanes->addInCondition('t.anio', $anios);
         if (count($cuats_unique) == 1) {
             $criteriaPlanes->addCondition("t.cuatrimestre==" . $cuats_unique[0]);
         }
         $materiasPlan = MateriaPlan::model()->findAll($criteriaPlanes);
         $materias = array();
         $matPlan = array();
         foreach ($materiasPlan as $value) {
             array_push($matPlan, $value->Materia_id);
         }
         foreach ($matPlan as $value) {
             if (!in_array($value, $materias, true)) {
                 array_push($materias, $value);
             }
         }
         //Obtengo los examenes de las materias dadas
         $criteriaMaterias = new CDbCriteria();
         $criteriaMaterias->select = 't.*';
         $criteriaMaterias->join = "INNER JOIN Tipo_Examen as tipoexamen ON(tipoexamen.id=t.tipoexamen_id)";
         $criteriaMaterias->addInCondition('t.materia_id', $materias);
         $criteriaMaterias->order = 't.fechaExamen ASC';
         $examenes = Examen::model()->findAll($criteriaMaterias);
         //Arreglo donde se guardaran los datos
         $datos = array();
         $datosNormalDate = $this->fechas;
         //Informacion que se devuelve  a la vista:
         // fecha del examen, dias de preparacion y peso de cada dia
         foreach ($examenes as $arr) {
             $fecha = $arr->fechaExamen;
             $dias = $arr->diasPreparacion;
             $complejidad = $arr->tipoexamen->complejidad;
             $utils->CalculateWeight($datos, $datosNormalDate, $fecha, $dias, $complejidad);
         }
         $resultados[$key->id] = $datosNormalDate;
     }
     header("Content-type: application/json");
     //Envio la informacion en formato jSON
     echo CJSON::encode(array('result' => $resultados));
 }
 public function actionGeneratePdf()
 {
     $session = new CHttpSession();
     $session->open();
     Yii::import('application.extensions.ajaxgii.bootstrap.*');
     require_once 'tcpdf/tcpdf.php';
     require_once 'tcpdf/config/lang/eng.php';
     if (isset($session['MateriaPlan_records'])) {
         $model = $session['MateriaPlan_records'];
     } else {
         $model = MateriaPlan::model()->findAll();
     }
     $html = $this->renderPartial('expenseGridtoReport', array('model' => $model), true);
     //die($html);
     $pdf = new TCPDF();
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(Yii::app()->name);
     $pdf->SetTitle('MateriaPlan Report');
     $pdf->SetSubject('MateriaPlan Report');
     //$pdf->SetKeywords('example, text, report');
     $pdf->SetHeaderData('', 0, "Report", '');
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Example Report by " . Yii::app()->name, "");
     $pdf->setHeaderFont(array('helvetica', '', 8));
     $pdf->setFooterFont(array('helvetica', '', 6));
     $pdf->SetMargins(15, 18, 15);
     $pdf->SetHeaderMargin(5);
     $pdf->SetFooterMargin(10);
     $pdf->SetAutoPageBreak(TRUE, 0);
     $pdf->SetFont('dejavusans', '', 7);
     $pdf->AddPage();
     $pdf->writeHTML($html, true, false, true, false, '');
     $pdf->LastPage();
     $pdf->Output("MateriaPlan_002.pdf", "I");
 }