* @version $Id$
* @access public
* @license http://opensource.org/licenses/gpl-3.0.html
*/
include_once(override('../project/' . SQL . '.inc.php'));
/**
* generate_html_recursive()
*
* @see : http://stackoverflow.com/questions/7577396/php-walking-and-print-multi-dimensional-array
* @param unknown $data
* @return string
*/
/**
*
* @param array $data
* @param unknown $statut
* @param unknown $filter
* @param unknown $id_filter
* @param unknown $depth
* @param unknown $display_first
* @return string
*/
if(!function_exists('generate_html_recursive')) {
function generate_html_recursive($data, $statut, $filter, $id_filter, $depth, $workshop_id =-1)
{
// begin with an empty html string
$html = '';
// loop through all items in this level
foreach($data as $key => &$item)
{
// echo "$key
";
// where only interested in numeric items
// as those are the actual children
if( !is_numeric( $key ) )
{
// otherwise continue
continue;
}
// 'level_parent' attribute is not set when there is no children level
if(isset($item['level_parent'])) {
// we display link only on main levels
$link_level = array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['level']['linkvalue'], 'id' => $item['level_id'], 'name' => $item['level_name']);
if($item['level_parent'] == 0) {
$html .= '
' . PHP_EOL;
} else {
$html .= '' . $item['level_name'] . '' . PHP_EOL;
}
}
// echo "
";
// print_r($data[$j]);
// echo "
";
// we pass the level ID to the SQL query
// Dirty but it works .....
// PRIORITY and SCALE filters are handle later when choosing to displaying or not the project
// See on the '$projects' loop
if($filter == 'TAG') {
$projects = $GLOBALS['sql_object']->DBSelect(SQL_getProjectsList(0, 999, $statut, 'LEVEL_TAG', $item['level_id'], $id_filter, $workshop_id));
} else {
$projects = $GLOBALS['sql_object']->DBSelect(SQL_getProjectsList(0, 999, $statut, 'LEVEL', $item['level_id'], $workshop_id));
}
// // we sort values on level names
// // Obtain a list of columns
// foreach ($projects as $key => $row) {
// $level[$key] = $row['level_name'];
// }
// // Sort the data with level descending
// // Add $projects as the last parameter, to sort by the common key
// array_multisort($level, SORT_DESC, $projects);
if ($projects != 0) {
$current_link = array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue']);
$current_level = '';
$html .= '' . PHP_EOL;
for($i = 0; $i < count($projects); $i++) {
$link_detail = array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue'], 'id' => $projects[$i]['project_id'], 'name' => $projects[$i]['project_name']);
$project_name = formatText($projects[$i]['complete_project_name'], '2HTML');
$project_description = formatText($projects[$i]['project_description'], '2HTML');
if($projects [$i] ['project_parent_id'] != 0) $class='sub-project'; else $class = 'project';
if($filter == 'PRIORITY') {
if($projects [$i]['priority_id'] == $id_filter) {
$html .= '
' . PHP_EOL;
$html .= '' . $project_name . '' . PHP_EOL;
$html .= '
' . PHP_EOL;
}
} elseif($filter == 'SCALE') {
if($projects [$i]['project_scale_id'] == $id_filter) {
$html .= '
' . PHP_EOL;
$html .= '' . $project_name . '' . PHP_EOL;
$html .= '
' . PHP_EOL;
}
// pas de filtre, on affiche tout !
} else {
$html .= '
' . PHP_EOL;
$html .= '' . $project_name . '' . PHP_EOL;
$html .= '
' . PHP_EOL;
}
}
$html .= '
' . PHP_EOL;
}
// call this funcion recursively
// with the next level ($item)
// it will figure out again whether that level has numeric children as well
// returns a new complete set, if applicable, otherwise an empty string
if(isset($item['children'])) $html .= generate_html_recursive($item['children'], $statut, $filter, $id_filter, $depth+1);
}
// return the resulting html
return $html;
}
}
/**
* DisplayListProjectByLevels()
* Affichage de la liste des projets publics par niveaux
*
* @param string $statut
* @param integer $filter
* @param string $id_filter
* @param integer $debut
* @return string $content
*/
if(!function_exists('DisplayListProjectByLevels')) {
function DisplayListProjectByLevels($statut, $filter, $id_filter)
{
$data = $GLOBALS['sql_object']->DBSelect(SQL_getLevelsList());
// we retrieve main levels
if($filter != 'LEVEL') {
$data = getLevelChildren($data, 0); // 0 is parentid
$sublevels = $id_filter;
$depth = 0;
} else {
$current = $GLOBALS['sql_object']->DBSelect(SQL_getoneLevel($id_filter));
$data = getLevelChildren($GLOBALS['sql_object']->DBSelect(SQL_getLevelsList()), $id_filter);
$sublevels = array_extract($data, 'level_id', true, 'children');
// if there is no sub-menu, we are working on last levels
// we emulate a level by passing choosen level but 'level_parent' is not set
if(count($sublevels) == 0) {
$sublevels = array($id_filter);
$data = $current;
}
$content = '' . $current[0]['level_name'] . '
' . PHP_EOL;
$content .= '' . $current[0]['level_desc_project'] . '
' . PHP_EOL;
$depth = 1;
}
echo '';
if(isset($content)) echo $content;
echo generate_html_recursive($data, $statut, $filter, $sublevels, $depth);
echo '
';
}
}
/**
* DisplayListProject()
* Affichage de la liste des projets publics
*
* @param string $statut
* @param integer $filter
* @param string $id_filter
* @param integer $debut
* @return string $content
*/
if(!function_exists('DisplayListProject')) {
function DisplayListProject($statut, $filter, $id_filter, $debut)
{
// getting tags
include_once('../class/class.tag.php');
if ($statut == 'public') {
$pas = 100;
$suffix = '';
} else $pas = SELECT_LIMIT;
$sep = ' / ';
if ($statut == 'archives_p') $suffix = ' "'.strtolower(_t('statut','PA')).'"';
$data = $GLOBALS['sql_object']->DBSelect(SQL_getProjectsList($debut, $pas, $statut, $filter, $id_filter));
$datacount = $GLOBALS['sql_object']->DBSelect(SQL_getCountProjectsList($statut, $filter, $id_filter));
$bdd_nb_com = $datacount[0]['num_rows'];
$bdd_nb_com_display = '' . $bdd_nb_com . ' ' . _t('project','name') . $suffix . '
' . PHP_EOL;
$content = '';
if ($data != 0) {
// echo $bdd_nb_com_display; // affichage du nombre d'enregistrements
$current_link = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue']);
$content .= get_linkin_page($current_link, $bdd_nb_com, $debut, $pas);
for($i = 0; $i < count($data); $i++) {
$levels = $GLOBALS['sql_object']->DBSelect(SQL_getLevelsList());
$level = getLevelParent($levels, $data[$i]['project_level_id'], 0);
if(is_array($level)) {
$link_level = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['level']['linkvalue'], 'id' => $level['id'], 'name' => $level['name']);
}
$link_detail = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'id' => $data[$i]['project_id'], 'name' => $data[$i]['project_name']);
$link_scale = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['scale']['linkvalue'], 'id' => $data[$i]['project_scale_id'], 'name' => $data[$i]['scale_denomination']);
$link_priority = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['priority']['linkvalue'], 'id' => $data[$i]['priority_id'] , 'name' => $data[$i]['priority_name']);
$link_user = array('rub' => $GLOBALS['links'][U_L]['user-profile']['linkvalue'], 'id' => $data[$i]['project_posted_by'], 'name' => $data[$i]['user_login']);
$link_tag = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => 'tag');
$project_name = formatText($data[$i]['complete_project_name'], '2HTML');
$project_description = formatText($data[$i]['project_description'], '2HTML');
$scale_denomination = formatText($data[$i]['scale_denomination'], '2HTML');
$project_posted_on = formatText($data[$i]['project_published_date_display'], '2HTML');
$project_posted_on_long = formatText($data[$i]['project_published_date_display_long'], '2ATT');
$project_posted_by = formatText($data[$i]['user_login'], '2HTML');
$project_priority = formatText($data[$i]['priority_name'], '2HTML');
$project_level_id = $data[$i]['project_level_id'];
$otag = new tag();
$tags = $otag->getTags('project', $data[$i]['project_id'], false);
$content .= '' . PHP_EOL;
$content .= '' . $project_name . '' . PHP_EOL;
$content .= '
' . PHP_EOL;
$content .= '' . PHP_EOL;
$content .= ''._t('statut','published_on') . ' ' . $project_posted_on . ' ';
$content .= _t('divers','by').' ' . $project_posted_by . '';
$content .= '
' . PHP_EOL;
$content .= '' . $project_description . '
' . PHP_EOL;
$content .= ''._t('btn', 'read_more').'';
$content .= '';
$content .= mb_ucfirst(_t('project','priority')) . ' :
' . mb_ucfirst($project_priority) . '' . $sep . PHP_EOL;
$content .= _t('divers','scale') . ' :
' . $scale_denomination . '' . $sep . PHP_EOL;
if(is_array($level)) $content .= ' ' . $level['label'] . ' :
' . $level['name'] . ''. PHP_EOL;
if(!empty($tags)) {
$content .= '
' . PHP_EOL;
$content .= mb_ucfirst(_t('tag','name')) . ' : ' . $otag->linkTags($tags, $link_tag). PHP_EOL;
$content .= '
' . PHP_EOL;
}
$content .= '
'.PHP_EOL;
if($i';
}
$content .= get_linkin_page($current_link, $bdd_nb_com, $debut, $pas);
echo $content;
}
}
/**
* DisplayOneProject()
* Affichage d'un projet en détail
*
* @param integer $project_id
* @return string $stat status name
*/
if(!function_exists('DisplayOneProject')) {
function DisplayOneProject($project_id)
{
$data = $GLOBALS['sql_object']->DBSelect(SQL_getoneCompleteProject($project_id, array('P', 'PA')));
$content = '';
if($data == 0) error_redirect();
// getting tags
include_once('../class/class.tag.php');
$otag = new tag();
$tags = $otag->getTags('project', $project_id, false);
$sep = ' / ';
if (count($data) != 1) exit;
else {
$link_scale = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['scale']['linkvalue'], 'id' => $data[0]['project_scale_id'], 'name' => $data[0]['scale_denomination']);
$link_priority = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['priority']['linkvalue'], 'id' => $data[0]['project_priority_id'], 'name' => $data[0]['project_priority']);
$link_user = array('rub' => $GLOBALS['links'][U_L]['user-profile']['linkvalue'], 'id' => $data[0]['project_posted_by'], 'name' => $data[0]['user_login']);
$link_parent = array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue'], 'id' => $data[0]['project_parent_id'], 'name' => $data[0]['parent_name']);
$link_self = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'id' => $project_id);
$link_tag = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue'], 'filter' => 'tag');
$project_coordinator = empty_nc(getAssociatedActors($project_id, 'coordinator'));
$project_partners = empty_nc(getAssociatedActors($project_id, 'partner'));
$project_managers = empty_nc(getAssociatedManagers($project_id));
$project_name = formatText($data[0]['project_name'], '2HTML');
$project_goal = formatText($data[0]['project_goal'], '2HTML');
$project_opgoal = formatText($data[0]['project_opgoal'], '2HTML');
$project_description = formatText($data[0]['project_description'], '2HTML');
$project_body = formatText($data[0]['project_body'], '2HTML');
$project_comment = formatText($data[0]['project_comment'], '2HTML');
$project_budget = formatText(empty_nc(fnumber_format($data[0]['project_budget'], 0, false)), '2HTML');
$project_budget_comment = formatText($data[0]['project_budget_comment'], '2HTML');
$project_team = formatText($data[0]['project_team'], '2HTML');
$project_elected = formatText($data[0]['project_elected'], '2HTML');
$project_parent = formatText($data[0]['parent_name'], '2HTML');
$project_scale = formatText($data[0]['scale_denomination'], '2HTML');
$project_priority = formatText($data[0]['project_priority'], '2HTML');
$project_begin_date = formatText(empty_nc($data[0]['project_begin_date_display']), '2HTML');
$project_estimated_date = formatText(empty_nc($data[0]['project_estimated_date_display']), '2HTML');
$project_end_date = formatText(empty_nc($data[0]['project_end_date_display']), '2HTML');
$project_progression = $data[0]['project_completed'];
$workshop_id = formatText(empty_nc($data[0]['project_workshop_id']), '2HTML');
$workshop_name = formatText(empty_nc($data[0]['workshop_denomination']), '2HTML');
$scale_id = $data[0]['project_scale_id'];
$project_level_id = $data[0]['project_level_id'];
$levels = $GLOBALS['sql_object']->DBSelect(SQL_getLevelsList());
$level = getLevelParent($levels, $data[0]['project_level_id'], 0);
if(is_array($level)) {
$link_level = array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['level']['linkvalue'], 'id' => $level['id'], 'name' => $level['name']);
}
$schedule_table = getScheduleTable($data[0]['project_begin_date_display'], $data[0]['project_estimated_date_display'], $data[0]['project_end_date_display']);
$project_posted_on = formatText($data[0]['project_published_date_display'], '2HTML');
$project_posted_on_long = formatText($data[0]['project_published_date_display_long'], '2ATT');
$project_modify_on = formatText($data[0]['project_last_modify_display'], '2HTML');
$project_posted_by = formatText($data[0]['user_login'], '2HTML');
$project_status = $data[0]['project_statut'];
if(commentEnabled('project')) {
postCommentAction(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $project_id));
$content .= ''.PHP_EOL;
}
$content .= '' . $project_name . '
' . PHP_EOL;
$content .= '' . PHP_EOL;
$content .= ''._t('statut','published_on') . ' ' . $project_posted_on . ' ';
$content .= _t('divers','by').' ' . $project_posted_by . '';
if ($project_status == 'PA') {
$content .= ' (' . _t('statut','archived_on') . ' ' . $project_modify_on . ')';
}
$content .= formatted_permalink($link_self, ' - ');
$content .= '
' . PHP_EOL;
if($data[0]['project_parent_id'] != 0) {
$content .= '' . PHP_EOL;
$content .= mb_ucfirst(_t('project','parent')) . ' : ';
$content .= '
' . $project_parent . ' ';
$content .= '
' . PHP_EOL;
}
if(!empty($project_goal)) $content .= ''.mb_ucfirst(_t('project', 'goal')).' : ' . $project_goal . '
' . PHP_EOL;
if(!empty($project_opgoal)) $content .= ''.mb_ucfirst(_t('project', 'opgoal')).' : ' . $project_opgoal . '
' . PHP_EOL;
if(!empty($project_comment)) $content .= 'Moyens : ' . $project_comment . '
' . PHP_EOL;
$content .= '' . PHP_EOL;
$content .= '
' . PHP_EOL;
$content .= '
' . $schedule_table . '
' . PHP_EOL;
$content .= '
'.mb_ucfirst( _t('project','progression')). '
' .getDynamicProgressbar($project_progression, 80). '
' . PHP_EOL;
$content .= '
' . PHP_EOL;
$content .= '
' . PHP_EOL;
if(defined('PROJECT_FINALITIES') && PROJECT_FINALITIES == 1) {
$content .= '' . _t('project','finalities') . '
';
$content .= getFinalities($project_id, 'read');
$content .= '';
}
$content .= '' . $project_description . '
' . PHP_EOL;
if(!empty($project_body)) $content .= '' . $project_body . '
' . PHP_EOL;
$content .= '';
$content .= '
';
$content .= '
';
$content .= '
' . _t('project','steering_title') . '
';
$content .= mb_ucfirst(_t('project','elected')) . ' :
' . empty_nc($project_elected) . '';
$content .= mb_ucfirst(_t('project','coordinator')) . ' :
' . $project_coordinator . '' . mb_ucfirst(_t('project','partners')) . ' :
' . $project_partners .'';
$content .= mb_ucfirst(_t('project','manager')) . ' :
' . $project_managers . '';
$content .= mb_ucfirst(_t('project','team')) . ' :
' . empty_nc($project_team) . '
';
$content .= '
';
$content .= '
';
$content .= '
' . _t('project','budget_title') . '
';
$content .= mb_ucfirst(_t('project','budget')). ' :
' . $project_budget . '';
if(!empty($project_budget_comment)) $content .= '
' . $project_budget_comment . '
';
$content .= '
';
$content .= '
' . PHP_EOL;
$content .= '
' . PHP_EOL;
$content .= getProjectChildren($project_id);
//$content .= getAssociatedIndicators($project_id, $scale_id);
$content .= getAssociatedIndicatorsValues($project_id);
$content .= getAssociatedWorkshop($workshop_id, $workshop_name);
$content .= '' . PHP_EOL;
$content .= mb_ucfirst(_t('project','priority')) . ' : ';
$content .= '
' . mb_ucfirst($project_priority) . '' . $sep . PHP_EOL;
$content .= ' ' . _t('divers','scale') . ' :
' . $project_scale . '' . $sep . PHP_EOL;
if(is_array($level)) $content .= ' ' . $level['label'] . ' :
' . $level['name'] . ''. $sep . PHP_EOL;
if(!empty($tags)) {
$content .= '
' . PHP_EOL;
$content .= ' ' . mb_ucfirst(_t('tag','name')) . ' : ' . $otag->linkTags($tags, $link_tag). PHP_EOL;
$content .= '
' . PHP_EOL;
}
$content .= '
' . PHP_EOL;
if(voteEnabled('project')) {
echo getAjaxVotesFunction(array('module' => 'project'));
$likes_number = getNbVotes(array('module' => 'project', 'module_id' => $project_id));
$content .= ''.PHP_EOL;
$content .= '
' . $likes_number . ' ' . _t('like', 'likes') .'
'.PHP_EOL;
$content .= '
'.PHP_EOL;
$content .= '
'.PHP_EOL;
}
}
// including sparkline code
footerAddJS('../lib/js/jquery.sparkline.min.js');
footerAddInlineJS("$('.inlinebar').sparkline('html', {type: 'bar', barColor: '#8DA8CB'} );");
echo $content;
return GetStatusName($project_status);
}
}
/**
* GetProjectChildren()
*
* @param $id
* @return string
*/
if(!function_exists('getProjectChildren')) {
function getProjectChildren($id)
{
$data = $GLOBALS['sql_object']->DBSelect(SQL_getProjectChildren($id));
$content = '';
if (is_array($data) && $data[0]!= 0) {
$content .= ''.PHP_EOL;
$content .= '
'.mb_ucfirst(_t('project','sub-projects')).' :
'.PHP_EOL;
for($i = 0; $i < count($data); $i++) {
$link = array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue'], 'id' => $data[$i]['project_id'], 'name' => $data[$i]['project_name']);
$name = formatText($data[$i]['project_name'], '2HTML');
$content .= '- ' . $name . '
' .PHP_EOL;
}
$content .= '
'.PHP_EOL;
}
return $content;
}
}
/**
* GetStatusName()
*
* @param $status
* @return $stat Status name
*/
if(!function_exists('GetStatusName')) {
function GetStatusName($status)
{
switch ($status) {
case 'P':
$stat = 'public';
break;
case 'PA':
$stat = 'archives_p';
break;
case 'AA':
$stat = 'archives_a';
break;
default:
$stat = 'public';
}
return $stat;
}
}
/**
* getScheduleTable()
*
* @param string $s_date
* @param string $es_date
* @param string $e_date
* @return string $content
*/
if(!function_exists('getScheduleTable')) {
function getScheduleTable($s_date, $es_date, $e_date) {
$es_date_class = 'nothing';
$e_date_class = 'nothing';
if(!isNullDate($es_date)) {
if(!isNullDate($e_date)) $es_date_class = date_compare($e_date, $es_date, '>') ? 'warn' : 'good';
else $es_date_class = date_compare(date("Y-m-d"), $es_date, '>') ? 'bad' : 'good';
}
if(!isNullDate($e_date)) {
if(!isNullDate($es_date)) $e_date_class = date_compare($e_date, $es_date, '>') ? 'bad' : 'good';
else $e_date_class = 'good';
} else {
if(!isNullDate($es_date)) {
$e_date_class = date_compare(date("Y-m-d"), $es_date, '>') ? 'warn' : 'nothing';
}
}
$content = ''.PHP_EOL;
$content .= ''.PHP_EOL;
$content .= ''.PHP_EOL;
$content .= ''.mb_ucfirst(_t('project','begin_date')).' | '.PHP_EOL;
$content .= ''.mb_ucfirst(_t('project','estimated_date')).' | '.PHP_EOL;
$content .= ''.mb_ucfirst(_t('project','end_date')).' | '.PHP_EOL;
$content .= '
'.PHP_EOL;
$content .= ''.PHP_EOL;
$content .= ''.PHP_EOL;
$content .= ''.PHP_EOL;
$content .= ''.formatText(empty_nc($s_date)).' | '.PHP_EOL;
$content .= ''.formatText(empty_nc($es_date)).' | '.PHP_EOL;
$content .= ''.formatText(empty_nc($e_date)).' | '.PHP_EOL;
$content .= '
'.PHP_EOL;
$content .= ''.PHP_EOL;
$content .= '
'.PHP_EOL;
return $content;
}
}
/**
* getAssociatedWorkshop()
*
* @param $id
* @return string
*/
if(!function_exists('getAssociatedWorkshop')) {
function getAssociatedWorkshop($wid, $wname)
{
$content = '';
if($wid != 0) {
$link = array('rub' => $GLOBALS['links'][U_L]['workgroup']['linkvalue'], 'id' => $wid, 'name' => $wname);
$content .= ''.PHP_EOL;
$content .= '
'.ucfirst(_t('project','workshop')).'
'.PHP_EOL;
$content .= '
' . $wname . '
' .PHP_EOL;
$content .= '
'.PHP_EOL;
}
return $content;
}
}
/**
* getFinalities()
*
* @param $id (optionnal)
* @param $mode (optionnal) : take value 'read' or 'write' or 'array'
* @param $selected (optionnal) : array with selected values - useful when adding / changing current values
* @return array
*/
if(!function_exists('getFinalities')) {
function getFinalities($id = false, $mode = 'read', $selected = array())
{
// we get all values
$init = $GLOBALS['sql_object']->DBSelect(SQL_getFinalities(false));
// we get finalities for the given project if needed
// and we merge all selected values in $selected array
if(is_numeric($id)) {
$data = $GLOBALS['sql_object']->DBSelect(SQL_getFinalities($id));
if(isset($data[0]['finality_id'])) {
foreach ($data as $item) {
if(!in_array($item['finality_id'], $selected)) array_push($selected, $item['finality_id']);
}
}
}
$content = '';
if (isset($init[0]['finality_id'])) {
$array = array();
if($mode == 'read' || $mode == 'array') {
$content .= '';
for($i = 0; $i < count($init); $i ++) {
$tmp = array();
$name = formatText($init[$i]['finality_name'], '2HTML');
$tmp['name'] = $name;
if(in_array($init[$i]['finality_id'], $selected)) {
$box='☑ ';
$tmp['state'] = 'active';
$tmp['state_utf8'] = '☑';
} else {
$box='☐ ';
$tmp['state'] = 'inactive';
$tmp['state_utf8'] = '☐';
}
$content .= '- '. $box . $name .'
';
$array[$i] = $tmp;
}
$content .= '
';
}
if($mode == 'write') $content = get_checkbox($init, 'finalities[]', 'finality_name', 'finality_id', $selected);
if($mode == 'array') $content = $array;
}
return $content;
}
}
/**
* getAssociatedActors()
*
* @param $id
* @param $type
* @return string
*/
if(!function_exists('getAssociatedActors')) {
function getAssociatedActors($id, $type)
{
$data = $GLOBALS['sql_object']->DBSelect(SQL_getAssociatedActors($id, $type));
$content = '';
$sep = '';
if (is_array($data) && $data[0]!= 0) {
for($i = 0; $i < count($data); $i++) {
$name = formatText($data[$i]['actor_name'], '2HTML');
$content .= $sep.$name;
$sep =', ';
}
}
return $content;
}
}
/**
* getAssociatedManagers()
*
* @param $id
* @return string
*/
if(!function_exists('getAssociatedManagers')) {
function getAssociatedManagers($id)
{
$data = $GLOBALS['sql_object']->DBSelect(SQL_getAssociatedManagers($id));
$content = '';
$sep = '';
if (is_array($data) && $data[0]!= 0) {
for($i = 0; $i < count($data); $i++) {
$name = formatText($data[$i]['user_login'], '2HTML');
$content .= $sep.$name;
$sep =', ';
}
}
return $content;
}
}
/**
* getAssociatedWorkshop()
*
* @param $id
* @return string
*/
if(!function_exists('getAssociatedIndicators')) {
function getAssociatedIndicators($id, $scale_id, $linkto = true)
{
$data = $GLOBALS['sql_object']->DBSelect(SQL_getProjectSdi($id));
$content = '';
if (count($data) != 0 && $data[0]!=0) {
$content .= ''.PHP_EOL;
$content .= '
'.ucfirst(_t('project','sdi')).'
'.PHP_EOL;
$content .= '
'.PHP_EOL;
for($i = 0; $i < count($data); $i++) {
$link = array('rub' => $GLOBALS['links'][U_L]['dashboard']['linkvalue'], 'id' => $data[$i]['sdii_id'], 'parentid' => $scale_id, 'name' => $data[$i]['sdii_name']);
$name = formatText($data[$i]['sdii_name'], '2HTML');
if($linkto) {
$content .= '- ' . $name . '
' .PHP_EOL;
} else {
$content .= '- ' . $name . '
' .PHP_EOL;
}
}
$content .= '
'.PHP_EOL;
}
return $content;
}
}
/**
* getAssociatedWorkshop()
*
* @param $id
* @return string
*/
if(!function_exists('getAssociatedIndicatorsValues')) {
function getAssociatedIndicatorsValues($id, $extraclass ='', $cursorcssposition = 0, $addvalues = false)
{
global $l21auth;
global $sql_object;
include_once('../dashboard/display.php');
include_once('../dashboard/mysql.inc.php');
$result_sdi = $GLOBALS['sql_object']->DBSelect(SQL_getProjectSdiValues($id));
$content = '';
$id_filter= 1; // scale id value
if (CURRENT_APP == 'admin' && ($l21auth->isProjectManager($l21auth->GetSessionElement('id'), $sql_object, $id) || $l21auth->isSuperAdmin())) {
$displayLink = true;
} else {
$displayLink = false;
}
if (is_array($result_sdi) && $result_sdi[0]!= 0) {
$content .= '" . PHP_EOL;
}
$js = '';
footerAddInlineJS($js, 'default', false);
return $content;
}
}
?>