Commit e7b2fc6d authored by John Punzalan's avatar John Punzalan

update Entity and news

parent 9bd2d955
...@@ -2,3 +2,7 @@ ...@@ -2,3 +2,7 @@
* All of the CSS for your admin-specific functionality should be * All of the CSS for your admin-specific functionality should be
* included in this file. * included in this file.
*/ */
.chosen-container-single {
height: 33px;
}
\ No newline at end of file
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
$('#radar_function').multiSelect(); $('#radar_function').multiSelect();
$('#industry_sub_id').multiSelect(); $('#industry_sub_id').multiSelect();
$('.join_sub_data_select').multiSelect(); $('.join_sub_data_select').multiSelect();
$('.js-multiselect').multiSelect();
$("#radar_id").live('change', function(el){ $("#radar_id").live('change', function(el){
$.ajax({ $.ajax({
......
...@@ -36,6 +36,8 @@ class Esi_Management_Entity_Form { ...@@ -36,6 +36,8 @@ class Esi_Management_Entity_Form {
wp_die( __( 'Permission Denied!', 'esi' ) ); wp_die( __( 'Permission Denied!', 'esi' ) );
} }
// var_dump($_POST);
// die;
$errors = array(); $errors = array();
$page_url = admin_url( 'admin.php?page=esi-management-entity' ); $page_url = admin_url( 'admin.php?page=esi-management-entity' );
...@@ -54,6 +56,7 @@ class Esi_Management_Entity_Form { ...@@ -54,6 +56,7 @@ class Esi_Management_Entity_Form {
$acquired_amount = isset( $_POST['acquired-amount'] ) ? (int)sanitize_text_field( $_POST['acquired-amount'] ) : ''; $acquired_amount = isset( $_POST['acquired-amount'] ) ? (int)sanitize_text_field( $_POST['acquired-amount'] ) : '';
$total_raised = isset( $_POST['total-raised'] ) ? (int)sanitize_text_field( $_POST['total-raised'] ) : ''; $total_raised = isset( $_POST['total-raised'] ) ? (int)sanitize_text_field( $_POST['total-raised'] ) : '';
$latest_round_type = isset( $_POST['latest-round-type'] ) ? (int)sanitize_text_field( $_POST['latest-round-type'] ) : ''; $latest_round_type = isset( $_POST['latest-round-type'] ) ? (int)sanitize_text_field( $_POST['latest-round-type'] ) : '';
$technology_ids = isset( $_POST['technology_id'] ) ? (int)sanitize_text_field( $_POST['technology_id'] ) : '';
if ($is_investor == "on") { if ($is_investor == "on") {
$is_investor = 1; $is_investor = 1;
...@@ -94,6 +97,7 @@ class Esi_Management_Entity_Form { ...@@ -94,6 +97,7 @@ class Esi_Management_Entity_Form {
'acquired_amount' => $acquired_amount, 'acquired_amount' => $acquired_amount,
'total_raised' => $total_raised, 'total_raised' => $total_raised,
'latest_round_type' => $latest_round_type, 'latest_round_type' => $latest_round_type,
'technology_ids' => $technology_ids
); );
// New or edit? // New or edit?
...@@ -110,6 +114,11 @@ class Esi_Management_Entity_Form { ...@@ -110,6 +114,11 @@ class Esi_Management_Entity_Form {
$insert_id = esi_insert_entity( $fields ); $insert_id = esi_insert_entity( $fields );
} }
// var_dump($fields['id']);
// die;
esi_save_list_entity_technology($insert_id, $technology_ids);
if($is_ajax){ if($is_ajax){
return $fields; return $fields;
} }
......
...@@ -190,3 +190,86 @@ function esi_get_list_industry( $id = 0 ) { ...@@ -190,3 +190,86 @@ function esi_get_list_industry( $id = 0 ) {
return $arrSelectedIndustry; return $arrSelectedIndustry;
} }
/**
* Fetch technologies array
*
* @param int $id
*
* @return array
*/
function esi_get_all_list_technology( $id = 0 ) {
global $wpdb;
// Get Selected technology mapping
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_technology ORDER BY name ASC");
return $arrSelectedTechnology;
}
/**
* Fetch technologies array
*
* @param int $id
*
* @return array
*/
function esi_get_list_entity_technology( $id = 0 ) {
global $wpdb;
// Get Selected technology mapping
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_technology_entity ORDER BY name ASC");
return $arrSelectedTechnology;
}
/**
* Fetch technologies array
*
* @param int $id
*
* @return array
*/
function esi_get_list_selected_entity_technology( $id = 0, $output = 'object' ) {
global $wpdb;
// Get Selected technology mapping
$arrSelectedTechnology = $wpdb->get_results("SELECT * FROM " .$wpdb->prefix . "esi_technology_entity WHERE entity_id = " . $id, OBJECT_K);
if ($output == 'array') {
$array = array();
foreach ($arrSelectedTechnology as $selected) {
$array [] = $selected->technology_id;
}
$arrSelectedTechnology = $array;
}
return $arrSelectedTechnology;
}
/**
* Fetch technologies array
*
* @param int $entityid
* @param array $technologyids
*
* @return array
*/
function esi_save_list_entity_technology( $entityid = 0, $technologyids = array() ) {
global $wpdb;
// Delete all current join from liaison table
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'esi_technology_entity WHERE entity_id = %d', $entityid));
// Insert new news_id technology_id relation
foreach ($technologyids as $technology_id) {
$wpdb->insert(
$wpdb->prefix . "esi_technology_entity",
array(
'technology_id' => $technology_id,
'entity_id' => intval($entityid)
));
}
}
\ No newline at end of file
...@@ -18,6 +18,9 @@ $countries = esi_get_all_countries(); ...@@ -18,6 +18,9 @@ $countries = esi_get_all_countries();
$entity_types = esi_get_all_entity_type_id(); $entity_types = esi_get_all_entity_type_id();
$industries = array(); $industries = array();
$industries = array_merge(esi_get_list_industry(), $industries); $industries = array_merge(esi_get_list_industry(), $industries);
$technologies = esi_get_all_list_technology();
$technologies_selected = esi_get_list_selected_entity_technology($id, 'array');
add_thickbox(); add_thickbox();
?> ?>
...@@ -175,6 +178,18 @@ add_thickbox(); ...@@ -175,6 +178,18 @@ add_thickbox();
</select><br /> </select><br />
</td> </td>
</tr> </tr>
<tr class="row-technology-id">
<th scope="row">
<label for="technology_id"><?php _e( 'Technology', 'esi' ); ?></label>
</th>
<td>
<select id="technology_id" class="chosen-select" name="technology_id[]" multiple="multiple">
<?php foreach ($technologies as $technology) : ?>
<option value="<?= $technology->id ?>" <?= (in_array($technology->id, $technologies_selected)) ? "selected='selected'" : ""?>><?= $technology->name ?></option>
<?php endforeach; ?>
</select><br />
</td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -139,14 +139,14 @@ add_thickbox(); ...@@ -139,14 +139,14 @@ add_thickbox();
<label for="entity_id"><?php _e( 'Entity', 'esi' ); ?></label> <label for="entity_id"><?php _e( 'Entity', 'esi' ); ?></label>
</th> </th>
<td> <td>
<select id="entity_id" name="entity_id" style="float:left"> <select id="entity_id" name="entity_id" class="chosen-select" style="float:left">
<option value="0">Select a entity</option> <option value="0">Select a entity</option>
<?php foreach ($companies as $entity) : ?> <?php foreach ($companies as $entity) : ?>
<option value="<?= $entity->id ?>" <?= ($item->entity_id == $entity->id)?'selected="selected"':'' ?>><?= $entity->name ?></option> <option value="<?= $entity->id ?>" <?= ($item->entity_id == $entity->id)?'selected="selected"':'' ?>><?= $entity->name ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<a href="/wp-admin/admin.php?page=esi-management-entity&action=new" target="_blank" <a href="/wp-admin/admin.php?page=esi-management-entity&action=new" target="_blank"
class="page-title-action" style="float:left;margin-top:5px;" > class="page-title-action" style="margin-top:5px;" >
Add entity Add entity
</a> </a>
</td> </td>
......
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