Commit 3446a1ff authored by John Punzalan's avatar John Punzalan

Update News

parent ba719dbe
......@@ -341,3 +341,35 @@ function esi_get_list_technology_news ( $newsid = 0 ) {
return $query;
}
/**
* Fetch technologies array
*
* @param int $id
*
* @return array
*/
function esi_get_list_selected_news_technology( $id = 0, $output = 'object' ) {
global $wpdb;
$query = $wpdb->get_results("
SELECT id, name
FROM " . $wpdb->prefix . "esi_technology
INNER JOIN " . $wpdb->prefix . "esi_technology_news
ON " . $wpdb->prefix . "esi_technology.id = " . $wpdb->prefix . "esi_technology_news.technology_id
WHERE news_id = " . $id . "
", OBJECT_K);
if ($output == 'array') {
$array = array();
foreach ($query as $selected) {
$array [] = $selected->id;
}
$query = $array;
}
return $query;
}
......@@ -57,6 +57,8 @@ $function_news = esi_get_function_by_news($id);
$technologies = esi_get_list_technology();
$selectedTechnologies = esi_get_list_technology_news($id);
$technologies_selected = esi_get_list_selected_news_technology($id, 'array');
add_thickbox();
?>
......@@ -196,26 +198,13 @@ add_thickbox();
<label for="technology_id"><?php _e( 'Technology', 'esi' ); ?></label>
</th>
<td>
<select id="technology_id" name="technology_id" class="join_data_select" data-tablename="technology" data-action="esi_technologies_ajax_action" data-populate=".join_sub_data_select">
<option value="0">Select a Technology</option>
<select id="technology_id" class="chosen-select" name="technology_sub_id[]" multiple="multiple">
<?php foreach ($technologies as $technology) : ?>
<option value="<?= $technology->id ?>"><?= $technology->name ?></option>
<option value="<?= $technology->id ?>" <?= (in_array($technology->id, $technologies_selected)) ? "selected='selected'" : ""?>><?= $technology->name ?></option>
<?php endforeach; ?>
</select><br />
</td>
</tr>
<tr class="row-entity-sub-industry">
<th scope="row">
Select Sub Technology <br/> (If needed)
</th>
<td>
<select id="technology_sub_id" name="technology_sub_id[]" class="join_sub_data_select" multiple="multiple">
<?php foreach ($selectedTechnologies as $activetechnology): ?>
<option value='<?= $activetechnology->id ?>' selected><?= $activetechnology->name ?></option>
<?endforeach;?>
</select><br />
</td>
</tr>
<tr class="row-type-id">
<th scope="row">
<label for="type_id"><?php _e( 'Type', 'esi' ); ?></label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment