public function getDecisionsApproachingDeadlineByMda($mda_id)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', EacDecision::model()->getDecisionIdsFromResponsibleMdaMappings($mda_id));
     $criteria->addInCondition("datediff(deadline,now())", [14, 7, 3]);
     $decisions = EacDecision::model()->find($criteria);
     return $decisions;
 }
Beispiel #2
0
 public function exportDecisions($export_key)
 {
     if (!Yii::app()->user->checkAccess("Export Decisions")) {
         throw new CHttpException(403, 'You are not authorized to access this feature');
     }
     if (isset($export_key)) {
         $export_key = $export_key;
     } else {
         throw new CHttpException(404, 'Invalid request');
     }
     //get decision source
     $decisionSourceModel = EacLookup::model()->find('`key` = :key', [':key' => $export_key]);
     $models = EacDecision::model()->findAll('decision_source_id = :id', [':id' => $decisionSourceModel->id]);
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     $phpExcelPath = Yii::getPathOfAlias('application.vendor.phpoffice');
     include $phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php';
     // Create new PHPExcel object
     $objPHPExcel = new PHPExcel();
     // Set properties
     $objPHPExcel->getProperties()->setCreator("EAMS Country TZ")->setLastModifiedBy("EAMs")->setTitle("EAMS TZ Decisions Export")->setSubject("EAMS TZ Decisions Export")->setDescription("EAMS TZ Decisions Export")->setKeywords("office 2007 openxml php")->setCategory("decisions");
     $objPHPExcel->getActiveSheet()->setTitle('decisions');
     // Add heading row
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Decision Reference')->setCellValue('B1', 'Description')->setCellValue('C1', 'Responsibility Center')->setCellValue('D1', 'Time Frame')->setCellValue('E1', 'Performance Indicators')->setCellValue('F1', 'Implementation Status')->setCellValue('G1', 'Status / Comments')->setCellValue('H1', 'ImplementationStatusID')->setCellValue('I1', 'id');
     $rowCount = 2;
     foreach ($models as $model) {
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$rowCount}", $model->decision_reference)->setCellValue("B{$rowCount}", $model->description)->setCellValue("C{$rowCount}", $model->responsibility_center)->setCellValue("D{$rowCount}", $model->time_frame)->setCellValue("E{$rowCount}", $model->performance_indicators)->setCellValue("F{$rowCount}", $model->implementation_status_id)->setCellValue("G{$rowCount}", $model->sectoral_council_id . 'Status / Comments')->setCellValue("H{$rowCount}", $model->implementation_status_id)->setCellValue("I{$rowCount}", $model->eams_central_id);
         $rowCount++;
     }
     // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     // header('Content-Disposition: attachment;filename="template.xlsx"');
     // header('Cache-Control: max-age=0');
     $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
     //$objWriter->save('php://output');
     $targetDir = Yii::getPathOfAlias('webroot') . '/uploads/exports/';
     $filename = 'desicion_export_' . md5(time() . uniqid('export', true)) . '.xlsx';
     $objWriter->save($targetDir . $filename);
     spl_autoload_register(array('YiiBase', 'autoload'));
     $fileExportModel = new EamsFilesExport();
     $fileExportModel->name = $filename;
     $fileExportModel->export_key = $export_key;
     $fileExportModel->mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
     $fileExportModel->file_extension = 'xlsx';
     $fileExportModel->file_size = filesize($targetDir . $filename);
     $fileExportModel->date_created = date('Y-m-d H:i:s');
     $fileExportModel->save();
     $this->sendFileToEamsCentral($fileExportModel);
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     $model = new EacStatusLog();
     $decision = EacDecision::model()->findByPk($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['EacStatusLog'])) {
         $model->attributes = $_POST['EacStatusLog'];
         $model->decision_id = $id;
         $model->approved = 0;
         //not approved
         $model->create_user_id = Yii::app()->user->id;
         $model->date_created = date('Y-m-d H:i:s');
         $model->date_updated = date('Y-m-d H:i:s');
         if ($model->save()) {
             if ($decision) {
                 $decision->implementation_status_id = $model->status_id;
                 $decision->save();
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Status updated successfully.');
             }
             $criteria = new CDbCriteria();
             $criteria->addColumnCondition(array('is_mda' => 0), 'OR');
             $mdas = $decision->getAssignedMdasIds();
             $criteria->addInCondition('mda_id', $mdas);
             $recipients = User::getNotificationSubscribers($criteria);
             $loggedInUser = User::model()->findByPk(Yii::app()->user->user_id);
             $from = "";
             if (Yii::app()->user->is_mda) {
                 $mda = $loggedInUser->mda;
                 $from = $mda->description;
             } else {
                 $meacOffice = $loggedInUser->meacOffice;
                 $from = $meacOffice->description;
             }
             $message = "Decision {$decision->decision_reference}-({$decision->description}) has been updated by " . Yii::app()->user->getState('loggedInUser') . " from {$from}<br />";
             $message .= $model->status_narrative . "<br />";
             $message .= "For more information click " . TbHtml::link("here", Yii::app()->getBaseUrl(true) . "/index.php?r=eacDecision/view&id={$decision->id}");
             $this->notify($recipients, 'Decision Update', $message);
             $this->redirect(array('/eacDecision/view', 'id' => $id));
         }
     }
     $this->render('create', array('model' => $model, 'decision' => $decision));
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return EacDecision the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = EacDecision::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #5
0
             <p><a href="<?php echo $this->createUrl('/eacDecision/admin',array('status'=>1))?>">(View all&nbsp;<span class="icon-arrow-right">&nbsp;</span>)</a></p>
         </div>
     </td>
 </tr>
 <tr >
     <td>
         <div style="width:95%;height:100%"  class="btn btn-danger">
             <div>Number of Decisions Approaching Deadline</div>
             <h2><?php echo EacDecision::getDecisionsApproachingDeadline(); ?></h2>
             <p><a href="<?php echo $this->createUrl('/eacDecision/admin',array('deadline'=>1))?>">(View all&nbsp;<span class="icon-arrow-right">&nbsp;</span>)</a></p>
         </div>
     </td>
     <td>
         <div style="width:95%;height:100%"  class="btn btn-info">
             <div>Number of Uploaded Decisions</div>
             <h2><?php echo EacDecision::model()->count(); ?></h2>
             <p><a href="<?php echo $this->createUrl('/eacDecision/admin'); ?>" >(View all&nbsp;<span class="icon-arrow-right">&nbsp;</span>)</a></p>
         </div>
     </td>
     <td>
         <div style="width:95%;height:100%"  class="btn btn-info">
             <div>Number of MDA Users</div>
             <h2><?php echo User::model()->count('is_mda=:is_mda', array(':is_mda' => 1)); ?></h2>
             <p><a href="<?php echo $this->createUrl('/user/mdas'); ?>">(View all&nbsp;<span class="icon-arrow-right">&nbsp;</span>)</a></p>
         </div>
     </td>
 </tr>
 <tr>
     <td>
         <div style="width:95%;height:100%"  class="btn btn-info">
             <div>Number of Users</div>