private function getYesNoDateFormated($field) { if ($field != 'N' && $field != '') { $field = convertToGlobalSettingFormat($field); $field = '<span class="text-success">' . $field . '</span>'; } elseif ($field != '') { $field = '<i class="fa fa-minus text-warning"></i>'; } return $field; }
/** * This function sends the shared participant info to the share panel using JSON encoding * This function is called after the share panel grid is loaded * This function returns the json depending on the user logged in by checking it from the session * @param it takes the session user data loginID * @return JSON encoded string containg sharing information */ function getTokens_json($iSurveyId, $search = null) { // CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}'); if (!$bTokenExists) { eT("No token table."); // return json ? error not treated in js. return; } if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'read')) { eT("We are sorry but you don't have permissions to do this."); // return json ? error not treated in js. return; } $page = (int) Yii::app()->request->getPost('page', 1); $limit = (int) Yii::app()->request->getPost('rows', 25); $sidx = Yii::app()->request->getPost('sidx', 'lastname'); $sord = Yii::app()->request->getPost('sord', 'asc'); if (strtolower($sord) != 'desc') { $sord = 'asc'; } $aData = new stdClass(); $aData->page = $page; $aSearchArray = Yii::app()->request->getPost('searcharray'); if (empty($search) && !empty($aSearchArray)) { $search = $aSearchArray; } if (!empty($search)) { $condition = TokenDynamic::model($iSurveyId)->getSearchMultipleCondition($search); } else { $condition = new CDbCriteria(); } $condition->order = Yii::app()->db->quoteColumnName($sidx) . " " . $sord; $condition->offset = ($page - 1) * $limit; $condition->limit = $limit; $tokens = Token::model($iSurveyId)->findAll($condition); $condition->offset = 0; $condition->limit = 0; $aData->records = Token::model($iSurveyId)->count($condition); if ($limit > $aData->records) { $limit = $aData->records; } if ($limit != 0) { $aData->total = ceil($aData->records / $limit); } else { $aData->total = 0; } Yii::app()->loadHelper("surveytranslator"); $format = getDateFormatData(Yii::app()->session['dateformat']); $aSurveyInfo = Survey::model()->findByPk($iSurveyId)->getAttributes(); //Get survey settings $attributes = getAttributeFieldNames($iSurveyId); // Now find all responses for the visible tokens $visibleTokens = array(); $answeredTokens = array(); if ($aSurveyInfo['anonymized'] == "N" && $aSurveyInfo['active'] == "Y") { foreach ($tokens as $token) { if (isset($token['token']) && $token['token']) { $visibleTokens[] = $token['token']; } } $answers = SurveyDynamic::model($iSurveyId)->findAllByAttributes(array('token' => $visibleTokens)); foreach ($answers as $answer) { $answeredTokens[$answer['token']] = $answer['token']; } } $bReadPermission = Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'read'); $bCreatePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'create'); $bTokenUpdatePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update'); $bTokenDeletePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'delete'); $bGlobalPanelReadPermission = Permission::model()->hasGlobalPermission('participantpanel', 'read'); foreach ($tokens as $token) { $aRowToAdd = array(); if ((int) $token['validfrom']) { $token['validfrom'] = date($format['phpdate'] . ' H:i', strtotime(trim($token['validfrom']))); } else { $token['validfrom'] = ''; } if ((int) $token['validuntil']) { $token['validuntil'] = date($format['phpdate'] . ' H:i', strtotime(trim($token['validuntil']))); } else { $token['validuntil'] = ''; } $aRowToAdd['id'] = $token['tid']; $action = ""; $action .= "<div class='inputbuttons'>"; // so we can hide this when edit is clicked // Check is we have an answer if (in_array($token['token'], $answeredTokens) && $bReadPermission) { // @@TODO change link $url = $this->getController()->createUrl("admin/responses/sa/viewbytoken/surveyid/{$iSurveyId}", array('token' => $token['token'])); $title = gT("View response details"); $action .= CHtml::link('<span class="inputbuttons-square glyphicon glyphicon-list-alt text-success" title="' . $title . '"></span>', $url, array('class' => 'imagelink')); } else { $action .= '<div style="width: 20px; height: 16px; float: left;"></div>'; } // Check if the token can be taken if ($token['token'] != "" && ($token['completed'] == "N" || $token['completed'] == "" || $aSurveyInfo['alloweditaftercompletion'] == "Y") && $bCreatePermission) { $action .= viewHelper::getIconLink('inputbuttons-square icon-do text-success', "survey/index/sid/{$iSurveyId}/token/{$token['token']}/lang/{$token['language']}/newtest/Y", gT("Do survey"), '_blank'); } else { $action .= '<div style="width: 20px; height: 16px; float: left;"></div>'; } // Add delete icon if ($bTokenDeletePermission) { $attribs = array('onclick' => 'if (confirm("' . gT("Are you sure you want to delete this entry?") . ' (' . $token['tid'] . ')")) {$("#displaytokens").delRowData(' . $token['tid'] . ');$.post(delUrl,{tid:' . $token['tid'] . '});}'); $action .= viewHelper::getIconLink('inputbuttons-square glyphicon glyphicon-trash text-warning', null, gT("Delete survey participant"), null, 'imagelink btnDelete', $attribs); } // Add email button if (strtolower($token['emailstatus']) == 'ok' && $token['email'] && $bTokenUpdatePermission) { if ($token['completed'] == 'N' && $token['usesleft'] > 0) { if ($token['sent'] == 'N') { $action .= viewHelper::getIconLink('inputbuttons-square icon-invite text-success', "admin/tokens/sa/email/surveyid/{$iSurveyId}/tokenids/" . $token['tid'], gT("Send invitation email to this person (if they have not yet been sent an invitation email)"), ""); } else { $action .= viewHelper::getIconLink('inputbuttons-square icon-remind text-success', "admin/tokens/sa/email/action/remind/surveyid/{$iSurveyId}/tokenids/" . $token['tid'], gT("Send reminder email to this person (if they have already received the invitation email)"), ""); } } else { $action .= '<div style="width: 20px; height: 16px; float: left;"></div>'; } } else { $action .= '<div style="width: 20px; height: 16px; float: left;"></div>'; } // Add edit button if ($bTokenUpdatePermission) { $action .= viewHelper::getIconLink('inputbuttons-square glyphicon glyphicon-pencil text-success', null, gT("Edit survey participant"), null, 'imagelink token_edit'); } // Add view button? if (!empty($token['participant_id']) && $token['participant_id'] != "" && $bGlobalPanelReadPermission) { $action .= viewHelper::getIconLink('inputbuttons-square icon-cpdb text-success', null, gT("View this person in the central participants database"), null, 'imagelink cpdb', array('onclick' => "sendPost('" . $this->getController()->createUrl('admin/participants/sa/displayParticipants') . "','',['searchcondition'],['participant_id||equal||{$token['participant_id']}']);")); } else { $action .= '<div style="width: 20px; height: 16px; float: left;"></div>'; } $action .= '</div>'; $sReminderSent = $token['remindersent']; $sCompleted = $token['completed']; if ($sReminderSent != 'N') { $sReminderSent = convertToGlobalSettingFormat($sReminderSent); } if ($sCompleted != 'N') { $sCompleted = convertToGlobalSettingFormat($sCompleted); } $aRowToAdd['cell'] = array($token['tid'], $action, htmlspecialchars($token['firstname'], ENT_QUOTES), htmlspecialchars($token['lastname'], ENT_QUOTES), htmlspecialchars($token['email'], ENT_QUOTES), htmlspecialchars($token['emailstatus'], ENT_QUOTES), htmlspecialchars($token['token'], ENT_QUOTES), htmlspecialchars($token['language'], ENT_QUOTES), htmlspecialchars($token['sent'], ENT_QUOTES), htmlspecialchars($sReminderSent, ENT_QUOTES), htmlspecialchars($token['remindercount'], ENT_QUOTES), htmlspecialchars($sCompleted, ENT_QUOTES), htmlspecialchars($token['usesleft'], ENT_QUOTES), htmlspecialchars($token['validfrom'], ENT_QUOTES), htmlspecialchars($token['validuntil'], ENT_QUOTES)); foreach ($attributes as $attribute) { $aRowToAdd['cell'][] = htmlspecialchars($token[$attribute], ENT_QUOTES); } $aData->rows[] = $aRowToAdd; } viewHelper::disableHtmlLogging(); header("Content-type: application/json"); echo ls_json_encode($aData); }
echo "1"; } ?> " /> </div> </div> <!-- Valid from to --> <div class="form-group"> <?php if (isset($validfrom) && $validfrom != 'N') { $validfrom = convertToGlobalSettingFormat($validfrom, true); } if (isset($validuntil) && $validuntil != 'N') { $validuntil = convertToGlobalSettingFormat($validuntil, true); } ?> <!-- From --> <label class="col-sm-2 control-label" for='validfrom'><?php eT("Valid from"); ?> :</label> <div class="col-sm-4 has-feedback"> <div id="validfrom_datetimepicker" class="input-group date"> <input class="YesNoDatePicker form-control" id="validfrom" type="text" value="<?php
/** * This method render the welcome/subscribe/key_updated message * @param obj $serverAnswer the answer return by the server */ private function _renderWelcome($serverAnswer) { if ($serverAnswer->result) { // Available views (in /admin/update/welcome/ ) $views = array('welcome', 'subscribe', 'key_updated', 'updater_update'); if (in_array($serverAnswer->view, $views)) { $sValidityDate = ''; if (isset($serverAnswer->key_infos->validuntil)) { $sValidityDate = convertToGlobalSettingFormat($serverAnswer->key_infos->validuntil); } return $this->controller->renderPartial('//admin/update/updater/welcome/_' . $serverAnswer->view, array('serverAnswer' => $serverAnswer, 'sValidityDate' => $sValidityDate), false, false); } else { $serverAnswer->result = FALSE; $serverAnswer->error = "unknown_view"; } } echo $this->_renderError($serverAnswer); }
/** * @todo Document code, please. */ public function getRunning() { // If the survey is not active, no date test is needed if ($this->active == 'N') { $running = '<a href="' . App()->createUrl('/admin/survey/sa/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . gT('Inactive') . '"><span class="fa fa-stop text-warning"></span></a>'; } elseif ($this->expires != '' || $this->startdate != '') { // Time adjust $sNow = date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime(date("Y-m-d H:i:s")))); $sStop = $this->expires != '' ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->expires))) : $sNow; $sStart = $this->startdate != '' ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->startdate))) : $sNow; // Time comparaison $oNow = new DateTime($sNow); $oStop = new DateTime($sStop); $oStart = new DateTime($sStart); $bExpired = $oStop < $oNow; $bWillRun = $oStart > $oNow; $sStop = convertToGlobalSettingFormat($sStop); $sStart = convertToGlobalSettingFormat($sStart); // Icon generaton (for CGridView) $sIconRunning = '<a href="' . App()->createUrl('/admin/survey/sa/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . gT('Expire') . ': ' . $sStop . '"><span class="fa fa-clock-o text-success"></span></a>'; $sIconExpired = '<a href="' . App()->createUrl('/admin/survey/sa/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . gT('Expired') . ': ' . $sStop . '"><span class="fa fa fa-step-forward text-warning"></span></a>'; $sIconFuture = '<a href="' . App()->createUrl('/admin/survey/sa/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . gT('Start') . ': ' . $sStart . '"><span class="fa fa-clock-o text-warning"></span></a>'; // Icon parsing if ($bExpired || $bWillRun) { // Expire prior to will start $running = $bExpired ? $sIconExpired : $sIconFuture; } else { $running = $sIconRunning; } } else { $running = '<a href="' . App()->createUrl('/admin/survey/sa/view/surveyid/' . $this->sid) . '" class="survey-state" data-toggle="tooltip" title="' . gT('Active') . '"><span class="fa fa-play text-success"></span></a>'; //$running = '<div class="survey-state"><span class="fa fa-play text-success"></span></div>'; } return $running; }