Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSCS17045 #2584

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions application/controllers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,8 @@ public function saverecordscron() {
$fields_count = $this->db->list_fields('zform_' . $form_id);
$fields_count = array_map('strtolower', $fields_count);
if (count($fields_count) < 90) {
$field = array($element => array('type' => 'VARCHAR', 'constraint' => 200, 'NULL' => TRUE));
$field = array($element => array('type' => 'VARCHAR',
'constraint' => 200, 'NULL' => TRUE));
$this->dbforge->add_column('zform_' . $form_id, $field, $after_field);
} else {
$field = array($element => array('type' => 'TEXT', 'NULL' => TRUE));
Expand All @@ -1284,12 +1285,15 @@ public function saverecordscron() {
}


$this->form_results_model->update_mobile_activity($activity_inserted_id, array('form_data_decoded' => json_encode($dataresultnew1)));
$this->form_results_model->update_mobile_activity($activity_inserted_id,
array('form_data_decoded' => json_encode($dataresultnew1)));
$ret_ins = $this->db->insert('zform_' . $form_id, $dataresultnew1);
$form_result_id_new = $this->db->insert_id();
if (!$ret_ins) {
$err_msg .= 'Record Not Submitted. ' . $this->db->_error_message() . '. "Please Refresh your application"';
$this->form_results_model->update_mobile_activity($activity_inserted_id, array('error' => $err_msg));
$err_msg .= 'Record Not Submitted. ' . $this->db->_error_message()
. '. "Please Refresh your application"';
$this->form_results_model->update_mobile_activity($activity_inserted_id,
array('error' => $err_msg));

continue;
}
Expand Down Expand Up @@ -1325,7 +1329,8 @@ public function saverecordscron() {
'image' => $image_path['image']
);
if(strpos($image_path ['title'], $form_info['security_key']) !== FALSE){
$add_images ['title'] = urldecode(base64_decode(str_replace($form_info ['security_key'], '', $image_path ['title'])));
$add_images ['title'] = urldecode(base64_decode(str_replace
($form_info ['security_key'], '', $image_path ['title'])));
} else {
$add_images ['title'] = urldecode($image_path ['title']);
}
Expand Down Expand Up @@ -1434,7 +1439,9 @@ public function saverecordsharzindagi() {
}

//Stop activity saving if already saved
$activity_aready_exist = $this->db->get_where('zform_'.$form_id, array('form_id' => $form_id, 'imei_no' => $imei_no,'activity_datetime' => $activity_datetime))->row_array();
$activity_aready_exist = $this->db->get_where('zform_'.$form_id,
array('form_id' => $form_id, 'imei_no' => $imei_no,'activity_datetime'
=> $activity_datetime))->row_array();
if ($activity_aready_exist) {
$jsone_array = array(
'success' => 'This activity already submitted.'
Expand All @@ -1455,8 +1462,10 @@ public function saverecordsharzindagi() {
$app_id = $form_info ['app_id'];
// Temprary block the record sending
$app_general_setting = get_app_general_settings($app_id);
if (isset($app_general_setting->record_stop_sending) && $app_general_setting->record_stop_sending == 1) {
$error_message = "Record receiving service currently not available. Please Try later";
if (isset($app_general_setting->record_stop_sending) &&
$app_general_setting->record_stop_sending == 1) {
$error_message = "Record receiving service currently"
$error_message .= "not available. Please Try later";
if ($app_general_setting->message_stop_sending_record != '') {
$error_message = $app_general_setting->message_stop_sending_record;
}
Expand Down Expand Up @@ -1508,7 +1517,8 @@ public function saverecordsharzindagi() {


// move the file
if ($s3->putObjectFile($fileTempName, $bucket_name, $imgName, S3::ACL_PUBLIC_READ)) {
if ($s3->putObjectFile($fileTempName, $bucket_name,
$imgName, S3::ACL_PUBLIC_READ)) {
$imgName = 'http://' . $bucket_name . '.s3.amazonaws.com/' . $imgName;
$temp_array = array(
'image' => $imgName,
Expand Down Expand Up @@ -1539,7 +1549,8 @@ public function saverecordsharzindagi() {
$error_before = array(
'file' => $data ['upload_data'] ['file_name']
);
$imgName = base_url() . 'assets/images/data/form-data/' . $data ['upload_data'] ['file_name'];
$imgName = base_url() . 'assets/images/data/form-data/'
. $data ['upload_data'] ['file_name'];
$temp_array = array(
'image' => $imgName,
'title' => $image_title
Expand Down Expand Up @@ -1575,7 +1586,8 @@ public function saverecordsharzindagi() {
$error_before = array(
'file' => $data ['upload_data'] ['file_name']
);
$imgName = base_url() . 'assets/images/data/form-data/' . $data ['upload_data'] ['file_name'];
$imgName = base_url() . 'assets/images/data/form-data/'
. $data ['upload_data'] ['file_name'];
$temp_array = array(
'image' => $imgName,
'title' => $image_title
Expand Down
61 changes: 42 additions & 19 deletions application/controllers/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,8 @@ public function update($slug) {
$data['upgrade_from_google_play'] = $upgrade_from_google_play;

$location_required = 1;
if (isset($app_general_setting->location_required) && $app_general_setting->location_required == 0) {
if (isset($app_general_setting->location_required) &&
$app_general_setting->location_required == 0) {
$location_required = 0;
}
$data['location_required'] = $location_required;
Expand All @@ -3423,7 +3424,9 @@ public function update($slug) {
if (!$this->acl->hasSuperAdmin()) {
$login_data = $this->session->userdata('logged_in');
if ($request_app['department_id'] != $login_data['login_department_id']) {
$this->session->set_flashdata('validate', array('message' => "You don't have enough permissions to do this task.", 'type' => 'warning'));
$this->session->set_flashdata('validate', array('message'
=> "You don't have enough permissions to do this task."
, 'type' => 'warning'));
redirect(base_url() . 'apps');
}
if ($request_app['user_id'] == $login_data['login_user_id']) {
Expand All @@ -3432,7 +3435,8 @@ public function update($slug) {
} else {
$data['super_app_user'] = 'yes';
}
$settings_exist = get_app_general_settings($app_id); //$this->app_model->get_app_settings($app_id);
$settings_exist = get_app_general_settings($app_id);
//$this->app_model->get_app_settings($app_id);
//print_r($app_general_setting);
$data['app_settings'] = $settings_exist;
$data['filter'] = $selected_form['filter'];
Expand Down Expand Up @@ -3489,7 +3493,8 @@ public function update($slug) {
$data['post_url'] = $selected_form['post_url'];
}
if ($history_id) {
$history_rec = $this->form_model->get_form_history($form_id, $view_id, $history_id);
$history_rec = $this->form_model->get_form_history
($form_id, $view_id, $history_id);
$data['description'] = $history_rec['description'];
}
$app = $this->app_model->get_app($app_id);
Expand All @@ -3502,13 +3507,16 @@ public function update($slug) {
$data['view_id'] = $view_id;
$app_id = $selected_form['app_id'];
if (!$this->acl->hasPermission('form', 'edit')) {
$this->session->set_flashdata('validate', array('message' => "You don't have enough permissions to do this task.", 'type' => 'warning'));
$this->session->set_flashdata('validate', array('message'
=> "You don't have enough permissions to do this task."
, 'type' => 'warning'));
redirect(base_url() . 'apps');
}
$session_data = $this->session->userdata('logged_in');
session_to_page($session_data, $data);
$data['active_tab'] = 'form_update';
$data['pageTitle'] = $app['name'] . '-' . $selected_form['name'] . ' Edit-' . PLATFORM_NAME;
$data['pageTitle'] = $app['name'] . '-'
. $selected_form['name'] . ' Edit-' . PLATFORM_NAME;
$this->load->view('templates/form_builder_header', $data);
$this->load->view('form/update', $data);
$this->load->view('templates/footer', $data);
Expand All @@ -3528,7 +3536,8 @@ public function appbuilder($slug) {
}
$this->load->library('form_validation');
if ($this->input->post()) {
$this->form_validation->set_rules('app_name', 'App Name', 'trim|required|xss_clean');
$this->form_validation->set_rules('app_name', 'App Name',
'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE) {
echo json_encode(array('status' => '2'));
exit;
Expand Down Expand Up @@ -3614,7 +3623,8 @@ public function add($slug) {
$data['app_id'] = $app_id;
$data['app_name'] = $app['name'];
if (!$this->acl->hasPermission('form', 'add')) {
$this->session->set_flashdata('validate', array('message' => "You don't have enough permissions to do this task.", 'type' => 'warning'));
$this->session->set_flashdata('validate', array('message' =>
"You don't have enough permissions to do this task.", 'type' => 'warning'));
redirect(base_url() . 'apps');
}
$session_data = $this->session->userdata('logged_in');
Expand All @@ -3638,8 +3648,10 @@ public function add($slug) {
$this->db->insert('form', $data);
$form_id = $this->db->insert_id();
updateDataBase($form_id, "");
//array parameters : action, description, before, after, app_id, app_name, form_id, form_name
$logary = array('action' => 'insert', 'description' => 'add new form', 'after' => json_encode($data));
//array parameters : action, description, before,
//after, app_id, app_name, form_id, form_name
$logary = array('action' => 'insert', 'description'
=> 'add new form', 'after' => json_encode($data));
addlog($logary);
//Get last inserted form id
$forms_by_app = $this->form_model->get_form_by_app($app_id);
Expand All @@ -3663,7 +3675,10 @@ public function add($slug) {
if (!$this->upload->do_upload('userfile_addform')) {

$this->data['error'] = $this->upload->display_errors();
$this->session->set_flashdata('validate', array('message' => $this->upload->display_errors() . ', Default icon has been embeded with your application.', 'type' => 'warning'));
$this->session->set_flashdata('validate', array('message' =>
$this->upload->display_errors()
. ', Default icon has been embeded with your application.',
'type' => 'warning'));
} else {
//success
$imageData = $this->upload->data();
Expand All @@ -3681,7 +3696,8 @@ public function add($slug) {
}
}
} else {
$from_path = FORM_IMG_DISPLAY_PATH . '../form_icons/default_' . $total_forms . '.png';
$from_path = FORM_IMG_DISPLAY_PATH . '../form_icons/default_'
. $total_forms . '.png';

@copy($from_path,$abs_path.$iconName);
// file_put_contents($abs_path . $iconName, file_get_contents($from_path));
Expand All @@ -3694,7 +3710,8 @@ public function add($slug) {
);
$this->db->where('id', $form_id);
$this->db->update('form', $change_next);
$this->session->set_flashdata('validate', array('message' => 'New form added successfully.', 'type' => 'success'));
$this->session->set_flashdata('validate', array('message' =>
'New form added successfully.', 'type' => 'success'));
redirect(base_url() . 'app-form/' . $form_id);
}

Expand Down Expand Up @@ -3733,7 +3750,8 @@ public function movetoview($slug) {
if($this->input->post()){
$form_id = $slug;//form_id which want to move to view

$view_id = $this->input->post('view_id');//view_id where want to move the selected form
$view_id = $this->input->post('view_id');
//view_id where want to move the selected form
$selected_form = $this->form_model->get_form($form_id,$view_id);
$app_id = $selected_form['app_id'];
$view_id_session = 0;
Expand All @@ -3758,7 +3776,8 @@ public function movetoview($slug) {
'post_url' => $selected_form['post_url']
);
//file_write()
file_write($abs_path.'/'.$view_id.'_'.$file_name_html,$selected_form['full_description']);
file_write($abs_path.'/'.$view_id.'_'.$file_name_html,
$selected_form['full_description']);

}
else{
Expand All @@ -3771,7 +3790,8 @@ public function movetoview($slug) {
'full_description' => $selected_view_form['fv_full_description'],
'post_url' => $selected_view_form['fv_post_url']
);
file_write($abs_path.'/'.$view_id.'_'.$file_name_html,$selected_view_form['fv_full_description']);
file_write($abs_path.'/'.$view_id.'_'.$file_name_html,
$selected_view_form['fv_full_description']);
}


Expand All @@ -3783,7 +3803,8 @@ public function movetoview($slug) {
$this->db->insert('form_views', $form_move_data);
}

$this->session->set_flashdata('validate', array('message' => 'Active form copied to your required view successfully', 'type' => 'success'));
$this->session->set_flashdata('validate', array('message' =>
'Active form copied to your required view successfully', 'type' => 'success'));
redirect(base_url() . 'app-form/' . $form_id);
}
} else {
Expand All @@ -3800,7 +3821,8 @@ public function copy($slug) {
if ($this->session->userdata('logged_in')) {
if($this->input->post()){
$form_id = $slug;//form_id which want to copy
$app_id = $this->input->post('app_id_popup');//app_id where want to copy the selected form
$app_id = $this->input->post('app_id_popup');
//app_id where want to copy the selected form



Expand Down Expand Up @@ -3829,7 +3851,8 @@ public function copy($slug) {
);
$this->db->insert('form', $data);
$form_id_new = $this->db->insert_id();
$old_file = './assets/images/data/form_icons/' . $selected_form['app_id'] . '/formicon_' . $slug . '.png';
$old_file = './assets/images/data/form_icons/'
$old_file .= $selected_form['app_id'] . '/formicon_' . $slug . '.png';
$new_file = './assets/images/data/form_icons/' . $app_id . '/formicon_' . $form_id_new . '.png';
$old = umask(0);
@mkdir('./assets/images/data/form_icons/' . $app_id, 0777);
Expand Down
Loading