public function get($bid, $name = null)
 {
     $_action = 'show';
     $_viewtype = 'book/show';
     $_viewdata = array('env' => $this->_env, 'action' => $_action, 'book_id' => $bid);
     $book = Book::find($bid);
     if (!$book) {
         // On vérifie si le livre existe en bdd, sinon erreur
         $_viewtype = 'error/nobook';
     } else {
         if (!$name) {
             // s'il n'y a pas de parametre name, on redirect avec le name
             $urlname = $book->urlname;
             return Redirect::to('book/' . $bid . '/' . $urlname . '/');
         } else {
             $db_urlname = $book->urlname;
             if ($db_urlname !== $name) {
                 // si le name en parametre n'est pas le meme qu'en base,
                 // on redirect avec le name de la bdd
                 return Redirect::to('book/' . $bid . '/' . $db_urlname . '/');
             } else {
                 // enfin OKLM
                 $_viewdata['author'] = Traveler::where('id', '=', $book->traveler_id)->first();
                 $_viewdata['book'] = $book;
                 $_viewdata['chapters'] = Chapter::where('book_id', '=', $bid)->get();
             }
         }
     }
     return View::make($_viewtype, $_viewdata);
 }
 public function get($bid, $name = null, $chid = 1)
 {
     $_action = 'show';
     $_viewtype = 'chapter/show';
     $_viewdata = array('env' => $this->_env, 'action' => $_action, 'book_id' => $bid, 'chapter_id' => $chid);
     if (!Book::find($bid)) {
         // On vérifie si le livre existe en bdd, sinon erreur
         $_viewtype = 'error/nobook';
     } else {
         if (!isset($name)) {
             // s'il n'y a pas de parametre name, on redirect avec le name
             $book = Book::find($bid);
             $urlname = $book->urlname;
             return Redirect::to('book/' . $bid . '/' . $urlname . '/chapter/' . $chid);
         } else {
             if (!Chapter::find($chid)) {
                 $_viewtype = 'error/nochapter';
             } else {
                 // on récupère l'urlname pour comparer à celui en parametre
                 $book = Book::find($bid);
                 $db_urlname = $book->urlname;
                 if ($db_urlname !== $name) {
                     // si le name en parametre n'est pas le meme qu'en base,
                     // on redirect avec le name de la bdd
                     return Redirect::to('book/' . $bid . '/' . $db_urlname . '/chapter/' . $chid);
                 } else {
                     $author = Traveler::where('id', '=', $book->traveler_id)->first();
                     $chapters = Chapter::where('book_id', '=', $bid)->get();
                     $_viewdata['book'] = $book;
                     $_viewdata['author'] = $author;
                     $_viewdata['chapters'] = $chapters;
                     if ($chapter = Chapter::where('book_id', '=', $bid)->where('id', '=', $chid)->first()) {
                         // chapitre spécifié existe
                         $elements = Element::where('chapter_id', '=', $chid)->orderBy('order', 'ASC')->get();
                         //var_dump(Request::ajax());
                         $_viewtype = Request::ajax() == true ? 'chapter/show-ajax' : 'chapter/show';
                         $_viewdata['chapter'] = $chapter;
                         $_viewdata['elements'] = $elements;
                     } else {
                         // chapitre spécifié n'existe pas
                         $_viewtype = 'error/nochapter';
                     }
                     // on retourne le livre
                     //Redirect::to('book/'.$bid.'/'.$db_urlname);
                 }
             }
         }
     }
     return View::make($_viewtype, $_viewdata);
 }
 public function signUp()
 {
     $_action = 'signup';
     $_viewtype = 'traveler/signin';
     $_viewdata = array('env' => $this->_env, 'action' => $_action);
     if (Auth::check()) {
         return Redirect::to('me/');
     } else {
         if (Request::isMethod('post')) {
             // pas connecté
             if (Request::isMethod('post')) {
                 $email = Input::get('email');
                 $username = Input::get('username');
                 $password = Input::get('password');
                 $dbuser = Traveler::where('email', '=', $email)->first();
                 if ($dbuser) {
                     // user existant
                     $_viewdata['error'] = array('code' => "emailused");
                 } else {
                     if (!Traveler::where('email', '=', $email)->first()) {
                         // ok create
                         $user = new Traveler();
                         $user->email = $email;
                         $user->username = $username;
                         $user->password = sha1($password);
                         $user->save();
                         Auth::login($user);
                         return Redirect::to('me/');
                     }
                 }
             }
             if (Request::isMethod('get') || Request::isMethod('post')) {
                 return View::make($_viewtype, $_viewdata);
             }
         }
     }
 }
예제 #4
0
 public function getTravelersList()
 {
     $new = Yii::t('default', 'New Version Pending');
     $travelerId = Issue::model()->findColumn('travelerId', 'equipmentId = ' . $this->id);
     $notIn = "";
     if ($travelerId) {
         $ids = '';
         foreach ($travelerId as $id) {
             $traveler = Traveler::model()->findByPk($id);
             if ($traveler->parentId) {
                 $ids .= $traveler->parentId . ',';
             } else {
                 $ids .= $traveler->id . ',';
             }
         }
         if ($ids != '') {
             $ids = substr($ids, 0, -1);
             $notIn = "AND (parentId NOT IN ({$ids}) OR parentId IS NULL)";
             //exit($notIn);
         }
     }
     $criteria = new CDbCriteria();
     /*$criteria->select = array("CASE status WHEN 0 THEN name+' (v'+CAST(revision as varchar)+')' ELSE name+' (v'+CAST(revision as varchar)+') -> !!$new' END as name", "id"); ORACLE*/
     $criteria->select = array("CASE status WHEN 0 THEN CONCAT(name, ' (v',   revision,  ')') ELSE CONCAT(name, ' (v', revision, ') -> !!{$new}') END as name", "id");
     $criteria->condition = "componentId = {$this->componentId} AND status < 1 {$notIn}";
     $criteria->addNotInCondition('id', $travelerId);
     $travelers = Traveler::model()->findAll($criteria);
     if ($travelers) {
         return CHtml::listData($travelers, 'id', 'name');
     } else {
         return false;
     }
 }
 public function actionexcelFile($id, $issueId)
 {
     if (!isset($issueId)) {
         $issueId = null;
     }
     Yii::import('ext.phpexcel.XPHPExcel');
     $columnCont = 1;
     $rowCont = 1;
     $newsheet = XPHPExcel::createPHPExcel();
     $element = Element::model()->findByPk($id);
     $i = 4;
     $r = 0;
     $resCol = Value::model()->findAll("elementId={$id}  and colonne=1");
     foreach ($element->columns as $colonne) {
         $newsheet->getActiveSheet()->setCellValueByColumnAndRow($columnCont, 1, $colonne->value);
         $i++;
         $columnCont++;
     }
     foreach ($element->rows as $row) {
         $rowCont++;
         $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $rowCont, $row->value);
         for ($index = 0; $index < $columnCont; $index++) {
             $res = $element->getResultTableForExcel($issueId, $id, $index, $r);
             if ($res != null) {
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow($index + 1, $r + 2, $res);
             }
         }
         $r++;
     }
     $columnLookup = array('A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13, 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26, 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13, 'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26);
     array_flip($columnLookup);
     for ($i = 1; $i < count($columnCont); $i++) {
         $newsheet->getActiveSheet()->getColumnDimension($columnLookup[$i])->setAutoSize(true);
     }
     $newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('G')->setAutoSize(true);
     $newsheet->getActiveSheet()->getColumnDimension('H')->setAutoSize(true);
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="myfile.xlsx');
     header('Cache-Control: max-age=0');
     //metada:
     $newsheet->getProperties()->setCreator(Yii::app()->user->username);
     // assign worksheet name
     $issue = $this->loadIssue($issueId);
     if (isset($issue)) {
         $traveler = Traveler::model()->findByPk($issue->travelerId);
         //$newsheet->getActiveSheet()->setTitle($traveler->name);
         $newsheet->getActiveSheet()->setTitle($issueId);
     }
     //create and send
     $objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
     $objWriter->save('php://output');
 }
 public function getTravelerName($id)
 {
     $id = (int) $id;
     $criteria = new CDbCriteria();
     $criteria->condition = "id={$id}";
     $issue = Issue::model()->find($criteria);
     //$issue= Issue::model()->findByPk($id); doesnt work!why?
     $traveler = Traveler::model()->findByPk($issue->travelerId);
     return $traveler->name;
 }
예제 #7
0
 public function init()
 {
     $this->travelers = Traveler::model()->findMyTravelers();
 }
 public function createTraveler()
 {
     $traveler = new Traveler();
     if (isset($_POST['Traveler'])) {
         $traveler->attributes = $_POST['Traveler'];
         if ($traveler->addStep($step)) {
             Yii::app()->user->setFlash('stepAdded', Yii::t('default', "Your step has been added"));
             $this->refresh();
         }
     }
 }
예제 #9
0
<?php

/* @var $this CommentController */
/* @var $dataProvider CActiveDataProvider */
if ($issue) {
    $issueId = $issue->id;
    $this->breadcrumbs = array(Yii::t('default', 'Equipments') => array('equipment/index'), $issue->equipment->identifier => array('equipment/view', 'id' => $issue->equipmentId), $issue->traveler->name => array('issue/view', 'id' => $issue->id), Yii::t('default', 'Comments'));
    $status = $issue->equipment->status;
} else {
    $this->breadcrumbs = array(Yii::t('default', 'Travelers') => array('traveler/index'), $travelerId => array('traveler/view', 'id' => $travelerId), Yii::t('default', 'Comments'));
    $status = Traveler::model()->findByPk($travelerId)->status;
}
?>

<h1>Comments</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view', 'viewData' => array('status' => $status)));
예제 #10
0
    <?php 
$ul = "";
$projectId = 0;
$componentId = 0;
$workId = 0;
$archive = "";
foreach ($query as $q) {
    $pname = $q['pname'];
    $pid = $q['pid'];
    $cname = $q['cname'];
    $cid = $q['cid'];
    $tname = $q['tname'];
    $tid = $q['tid'];
    $project = Project::model()->findByPk($pid);
    $component = Components::model()->findByPk($cid);
    $traveler = Traveler::model()->findByPk($tid);
    if ($projectId != $pid) {
        $componentId = 0;
        $workId = 0;
        $status = 0;
        if (Preference::model()->hideArchive) {
            $styleA = "";
        } else {
            $styleA = "style='display:none'";
        }
        if ($project->hide) {
            $style = "";
        } else {
            $style = "style='display:none'";
        }
        ?>
예제 #11
0
 public function actionexcelComp($id, $elementId)
 {
     //issueId and elementId
     $element = Element::model()->findByPk($elementId);
     Yii::import('ext.phpexcel.XPHPExcel');
     $title = Element::model()->findByPk($elementId);
     $newsheet = XPHPExcel::createPHPExcel();
     switch ($element->typeId) {
         case 0:
         case 1:
         case 3:
         case 4:
             $criteria = "elementId={$elementId}";
             $results = Result::model()->findAll($criteria);
             //$results=Result::model()->findAll($title->label);
             $newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, 1, "Issue ID");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 1, "User");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, 1, "Fill date");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, 1, $title->label);
             $newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
             $cont = 2;
             foreach ($results as $result) {
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $cont, $result->issueId);
                 $issue = $this->loadIssue($result->issueId);
                 $user = Element::model()->getUserForExcel($result->issueId, $elementId);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, $cont, $user);
                 //
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, $cont, Yii::app()->dateFormatter->format("HH:mm d/M/y", $result->createTime));
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, $cont, $result->value);
                 $cont++;
             }
             $traveler = Traveler::model()->findByPk($issue->travelerId);
             if (isset($issue)) {
                 if (strlen($traveler->name) > 28) {
                     $traveler->name = substr($traveler->name, 0, 28);
                 }
                 $newsheet->getActiveSheet()->setTitle($traveler->name);
             }
             //else throw new CHttpException(403, 'There is a problem with the data');
             header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
             header('Content-Disposition: attachment;filename="myfile.xlsx');
             header('Cache-Control: max-age=0');
             //metada:
             $newsheet->getProperties()->setCreator(Yii::app()->user->username);
             $objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
             $objWriter->save('php://output');
             break;
         case 5:
             //devuelve el value de result, que es el id de value!!
             //center 1st column
             $newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             //name first column
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, 1, "Issue ID");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 1, "User");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, 1, "Fill date");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, 1, $title->label);
             //center data cells
             $newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             //color
             $newsheet->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             //size
             $newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
             $criteria = "elementId={$elementId}";
             $preresults = Result::model()->findAll($criteria);
             $cont = 2;
             foreach ($preresults as $preresult) {
                 $issue = $this->loadIssue($preresult->issueId);
                 $user = Element::model()->getUserForExcel($preresult->issueId, $elementId);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $cont, $preresult->issueId);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, $cont, $user);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, $cont, Yii::app()->dateFormatter->format("HH:mm d/M/y", $preresult->createTime));
                 $value = Value::model()->findByPk($preresult->value);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, $cont, $value->value);
                 $cont++;
             }
             if (isset($issue)) {
                 $traveler = Traveler::model()->findByPk($issue->travelerId);
                 $newsheet->getActiveSheet()->setTitle($traveler->name);
             }
             header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
             header('Content-Disposition: attachment;filename="myfile.xlsx');
             header('Cache-Control: max-age=0');
             //metada:
             $newsheet->getProperties()->setCreator(Yii::app()->user->username);
             $objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
             $objWriter->save('php://output');
             break;
         case 6:
         case 7:
             //center 1st column
             $newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             $newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
             //name first column
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, 1, "Issue ID");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 1, "User");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, 1, "Fill date");
             $newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, 1, $title->label);
             //center data cells
             $newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             $newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
             //color
             $newsheet->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             $newsheet->getActiveSheet()->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
             //size
             $newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
             $newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
             //saber numero de issues
             $criteria = new CDbCriteria();
             $criteria->distinct = true;
             $criteria->condition = "elementId=" . $elementId;
             $criteria->select = "issueId";
             $issues = Result::model()->findAll($criteria);
             $contCol = 0;
             $cont = array();
             $cont = 1;
             //looping through results by issues!!!
             foreach ($issues as $issue) {
                 $user = null;
                 $cont++;
                 $results = Result::model()->findAll("elementId={$elementId} and issueId={$issue->issueId}");
                 $contCol = 3;
                 $newest = Date('1970-01-21 00:00:00.0');
                 foreach ($results as $result) {
                     //$user=Element::model()->getUserForExcel7($result->issueId, $elementId, $result->value);
                     //$newsheet->getActiveSheet()->setCellValueByColumnAndRow(1+$userColumn,$cont+1,$user);
                     $date = $result->createTime;
                     if ($date > $newest) {
                         $newest = $date;
                         $user = $result->userId;
                         $user = Element::model()->getUserForExcel($result->issueId, $elementId);
                     }
                     if (!is_numeric($result->value)) {
                         $newsheet->getActiveSheet()->setCellValueByColumnAndRow($contCol, $cont, "NULL");
                         $contCol++;
                         $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $cont, $result->issueId);
                     } else {
                         $criteria = "elementId={$elementId} and id={$result->value}";
                         $values = Value::model()->find($criteria);
                         $newsheet->getActiveSheet()->setCellValueByColumnAndRow($contCol, $cont, $values->value);
                         $contCol++;
                         $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $cont, $result->issueId);
                     }
                     //else  throw new CHttpException(404, 'There is a problem with the data.');
                     $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, $cont, $user);
                 }
                 $newest = Yii::app()->dateFormatter->format("HH:mm d/M/y", $newest);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, $cont, $user);
                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, $cont, $newest);
                 /*
                 					
                 					//esto es para cargar el nombre del traveler en el nombre de la hoja de calculo, no funciona porque no está bien cargado el issue
                 					if(isset($issue)){
                 						$traveler=Traveler::model()->findByPk($issue->travelerId);
                 					
                 						$newsheet->getActiveSheet()->setTitle($traveler->name);
                 					}*/
             }
             if ($contCol <= 26 && $contCol > 0) {
                 $columnLookup = array(1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd', 5 => 'e', 6 => 'f', 7 => 'g', 8 => 'h', 9 => 'i', 10 => 'j', 11 => 'k', 12 => 'l', 13 => 'm', 14 => 'n', 15 => 'o', 16 => 'p', 17 => 'q', 18 => 'r', 19 => 's', 20 => 't', 21 => 'u', 22 => 'v', 23 => 'w', 24 => 'x', 25 => 'y', 26 => 'z');
                 $mergeCells = "d1:" . $columnLookup[$contCol] . "1";
                 $newsheet->setActiveSheetIndex(0)->mergeCells($mergeCells);
             }
             header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
             header('Content-Disposition: attachment;filename="myfile.xlsx');
             header('Cache-Control: max-age=0');
             //metada:
             $newsheet->getProperties()->setCreator(Yii::app()->user->username);
             $objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
             $objWriter->save('php://output');
             break;
         case 13:
         case 14:
             $criteria = new CDbCriteria();
             $criteria->distinct = true;
             $criteria->condition = "elementId=" . $elementId;
             $criteria->select = "issueId";
             $issues = Result::model()->findAll($criteria);
             $sheetNumber = 0;
             foreach ($issues as $issue) {
                 $myWorkSheet = new PHPExcel_Worksheet($newsheet, $issue->issueId);
                 $newsheet->addSheet($myWorkSheet);
                 $newsheet->setActiveSheetIndex($sheetNumber + 1);
                 $sheetNumber++;
                 $criteria = "elementId={$elementId}";
                 $results = Result::model()->findAll($criteria);
                 $cont = 1;
                 $contCol = 0;
                 $columnCont = 1;
                 $rowCont = 1;
                 $element = Element::model()->findByPk($elementId);
                 $i = 4;
                 $r = 0;
                 $resCol = Value::model()->findAll("elementId={$elementId}  and colonne=1");
                 foreach ($element->columns as $colonne) {
                     $newsheet->getActiveSheet()->setCellValueByColumnAndRow($columnCont, 1, $colonne->value);
                     $i++;
                     $columnCont++;
                 }
                 foreach ($element->rows as $row) {
                     $rowCont++;
                     $newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $rowCont, $row->value);
                     for ($index = 0; $index < $columnCont; $index++) {
                         $res = $element->getResultTableForExcel($issue->issueId, $elementId, $index, $r);
                         switch ($res) {
                             case "off":
                                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow($index + 1, $r + 2, "No");
                                 break;
                             case "checked":
                                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow($index + 1, $r + 2, "Yes");
                                 break;
                             default:
                                 $newsheet->getActiveSheet()->setCellValueByColumnAndRow($index + 1, $r + 2, $res);
                         }
                     }
                     $r++;
                 }
                 $newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
                 $newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
                 $newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
                 $newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
                 $newsheet->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
             }
             header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml0sheet');
             header('Content-Disposition: attachment;filename="myfile.xlsx');
             header('Cache-Control: max-age=0');
             $newsheet->removeSheetByIndex(0);
             $objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
             $objWriter->save('php://output');
             break;
     }
 }
예제 #12
0
<ul>
    
    <?php 
$myIssues = $this->getMyIssues();
$cont = 1;
if ($myIssues) {
    foreach ($myIssues as $myIssue) {
        $id = $myIssue->travelerId;
        $traveler = Traveler::model()->find("id={$id}");
        echo "<span class='issue'>{$cont}.-  " . CHtml::link($traveler->name . "- ", array('issue/view', 'id' => $myIssue->id), array('onclick' => 'mostra_loading_screen()')) . $myIssue->statusText . "</br></span>";
        $cont++;
    }
} else {
    echo Yii::t('default', 'None');
}
//CHtml::link("(v" . $myIssue->revision . ") " . $myIssue->statusText, array('view', 'id' => $myIssue->id))."</br>";
?>
</ul>
예제 #13
0
 public function getLastRevision()
 {
     if ($this->parentId) {
         $id = $this->parentId;
     } else {
         $id = $this->id;
     }
     $criteria = new CDbCriteria();
     $criteria->select = 'MAX(revision) as revision';
     $criteria->condition = "parentId = {$id}";
     $lastRev = Traveler::model()->find($criteria);
     return (int) $lastRev->revision;
 }