Commit 4469d04b authored by John Punzalan's avatar John Punzalan

Update Entity

parent 260e2e28
......@@ -49,11 +49,12 @@ class Esi_Management_Entity_Form {
$entity_type_id = isset( $_POST['entity_type_id'] ) ? sanitize_text_field( $_POST['entity_type_id'] ) : '';
$employees = isset( $_POST['employees'] ) ? (int)sanitize_text_field( $_POST['employees'] ) : '';
$founded_date = isset( $_POST['founded-date'] ) ? sanitize_text_field( $_POST['founded-date'] ) : '';
$acquired_by = isset( $_POST['acquired'] ) ? intval( $_POST['acquired'] ) : '';
$acquired_date = isset( $_POST['acquired-date'] ) ? sanitize_text_field( $_POST['acquired-date'] ) : '';
$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'] ) : '';
$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'] ) : '';
$technology_ids = isset( $_POST['technology_id'] ) ? ( $_POST['technology_id'] ) : '';
if ($is_investor == "on") {
$is_investor = 1;
......@@ -90,11 +91,11 @@ class Esi_Management_Entity_Form {
'entity_type_id' => $entity_type_id,
'employees' => $employees,
'founded_in' => $founded_date,
'acquired_by' => $acquired_by,
'acquired_at' => $acquired_date,
'acquired_amount' => $acquired_amount,
'total_raised' => $total_raised,
'latest_round_type' => $latest_round_type,
'technology_ids' => $technology_ids
'latest_round_type' => $latest_round_type
);
// New or edit?
......@@ -111,7 +112,7 @@ class Esi_Management_Entity_Form {
$insert_id = esi_insert_entity( $fields );
}
esi_save_list_entity_technology($insert_id, $technology_ids);
esi_save_list_entity_technology($fields['id'], $technology_ids);
if($is_ajax){
return $fields;
......
......@@ -191,6 +191,32 @@ function esi_get_list_industry( $id = 0 ) {
return $arrSelectedIndustry;
}
/**
* Fetch technologies array
*
* @param int $id
*
* @return array
*/
function esi_get_list_selected_entity_industry( $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
*
......
......@@ -20,7 +20,8 @@ $industries = array();
$industries = array_merge(esi_get_list_industry(), $industries);
$technologies = esi_get_all_list_technology();
$technologies_selected = esi_get_list_selected_entity_technology($id, 'array');
$investment_type = esi_get_all_investment_type(array('number' => 10000));
$entities = esi_get_all_entity(array('number' => 10000));
add_thickbox();
?>
......@@ -119,8 +120,12 @@ add_thickbox();
<label for="acquired-by"><?php _e( 'Acquired by', 'esi' ); ?></label>
</th>
<td>
<select id="acquired" name="acquired">
<select id="acquired" name="acquired" class="chosen-select">
<option value="0">Select an entity</option>
<?php foreach ($entities as $entity) : ?>
<option value="<?= $entity->id ?>" <?= ($item->acquired_by == $entity->id)?'selected="selected"':'' ?>><?= $entity->name ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
......@@ -153,7 +158,12 @@ add_thickbox();
<label for="latest-round-type"><?php _e( 'Latest Round Type', 'esi' ); ?></label>
</th>
<td>
<input type="text" name="latest-round-type" id="latest-round-type" class="regular-text" placeholder="<?php echo esc_attr( 'Latest Round Type', 'esi' ); ?>" value="<?php echo ($item)?esc_attr( $item->latest_round_type ):''; ?>" />
<select id="latest-round-type" name="latest-round-type" class="chosen-select" style="float:left">
<option value="0">Select an investment type</option>
<?php foreach ($investment_type as $type) : ?>
<option value="<?= $type->id ?>" <?= ($item->latest_round_type == $type->id)?'selected="selected"':'' ?>><?= $type->name ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<hr />
......
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