public function update_column() { $ObjCUF = new contactsUploadedFileModel(); $ObjCUFF = new contactsUploadedFileFieldsModel(); $name = 'Unnamed'; $result = ''; $column_no_prev = Input::get('record_column_no'); $status_prev = Input::get('record_status'); $cuf_id = Input::get('cuf_id'); $cuff_id = Input::get('cuff_id'); $column_no = Input::get('column_no'); $fieldname = Input::get('fieldname'); $task = Input::get('task'); $cuff_id_list = Input::get('cuff_id_list'); $cuff_id_array = explode(',', $cuff_id_list); $cuff_count = count($cuff_id_array); $response['reply'] = FALSE; //$colprev = $ObjCUFF->get_record( array('`cuf_id`='=>$cuf_id,'`cuff_edit`='=>'yes') ); if ($cuff_id) { //if( $colprev ){ $edit_prev = 'no'; if ($task == 'back') { $status_prev = 'close'; $column_no_next = $column_no > 1 ? $column_no - 1 : 1; } elseif ($task == 'skip') { $status_prev = 'skip'; $column_no_next = $column_no < $cuff_count ? $column_no + 1 : 1; } else { $name = $ObjCUF->get_column_name_by_filename($fieldname); $data[$ObjCUFF->tblpref . 'name'] = $name; $data[$ObjCUFF->tblpref . 'fieldname'] = $fieldname; $status_prev = 'close'; $column_no_next = $column_no < $cuff_count ? $column_no + 1 : 1; } $cuff_id_prev = $cuff_id; //$cuff_id_prev = $colprev->cuff_id; //$data[$ObjCUFF->tblpref.'status'] = $status_prev; //$data[$ObjCUFF->tblpref.'edit'] = $edit_prev; //$result = $ObjCUFF->update_data( $data, $cuff_id_prev ); $data[$ObjCUFF->tblpref . 'status'] = $status_prev; $data[$ObjCUFF->tblpref . 'edit'] = $edit_prev; $result = $ObjCUFF->update_data($data, $cuff_id_prev); if ($result) { $status_next = 'open'; $edit_next = 'yes'; $button_prev = $ObjCUFF->column_buttons($status_prev, $edit_prev, $cuff_id_prev, $column_no, $cuff_count); $colprev = $ObjCUFF->get_record_by_id($cuff_id_prev); $fieldname_prev = $colprev->cuff_fieldname; $key = $column_no_next - 1; $cuff_id_new = $cuff_id_array[$key]; if ($column_no == $cuff_count) { $button_next = ''; } else { $data = array($ObjCUFF->tblpref . 'status' => $status_next, $ObjCUFF->tblpref . 'edit' => $edit_next); $result = $ObjCUFF->update_data($data, $cuff_id_new); $button_next = $ObjCUFF->column_buttons($status_next, $edit_next, $cuff_id_new, $column_no_next, $cuff_count); } $response['reply'] = TRUE; $colnext = $ObjCUFF->get_record_by_id($cuff_id_new); $fieldname_next = $colnext->cuff_fieldname; if ($task == 'skip' && $edit_next == 'no') { $field_selection_next = 'Skipped will not be imported.'; } else { $used_fieldnames_array = $ObjCUFF->get_used_fieldnames_by_cuf_id($cuf_id); $field_selection_next = $ObjCUF->select_column_name($fieldname_next, $cuff_id_new, $used_fieldnames_array, $edit_next); } if ($task == 'skip') { $field_selection_prev = 'Skipped will not be imported.'; } else { $used_fieldnames_array = $ObjCUFF->get_used_fieldnames_by_cuf_id($cuf_id); $field_selection_prev = $ObjCUF->select_column_name($fieldname_prev, $cuff_id_prev, $used_fieldnames_array, $edit_prev); } $response['button_wrapper_next'] = $button_next; $response['status_next'] = $status_next; $response['column_no_next'] = $column_no_next; $response['cuff_id_next'] = $cuff_id_new; $response['field_selection_next'] = $field_selection_next; } $response['name_prev'] = $name; $response['fieldname_prev'] = $fieldname_prev; $response['button_wrapper_prev'] = $button_prev; $response['status_prev'] = $status_prev; $response['field_selection_prev'] = $field_selection_prev; } echo json_encode($response); exit; }
public function uploaded_contacts_save($cuf_id) { $ObjContacts = new contactsModel(); $ObjCompanies = new companiesModel(); $ObjCUF = new contactsUploadedFileModel(); $ObjCUFF = new contactsUploadedFileFieldsModel(); $result = FALSE; $uploaded_file_col = $this->get_record_join(array('`j1`.`cuf_id`=' => $cuf_id)); $contact_id = $uploaded_file_col->contact_id; $cuff_rows = $ObjCUFF->get_records(array('`cuf_id`=' => $cuf_id)); $header_format = $this->get_fieldname_column($cuff_rows); $where_params = array('`cuf_id`=' => $cuf_id); $order_params = array('ASC' => 'cut_id'); $uploaded_contacts_rows = $this->get_records($where_params, $order_params); if ($uploaded_contacts_rows) { foreach ($uploaded_contacts_rows as $col) { $cut_id = $col->cut_id; $this->update_uploaded_contacts_value($cuff_rows, $cut_id); } } $where_params = array('`cuf_id`=' => $cuf_id); $order_params = array('ASC' => 'cut_id'); $uploaded_contacts_rows = $this->get_records($where_params, $order_params); if ($uploaded_contacts_rows) { foreach ($uploaded_contacts_rows as $col) { $cut_id = $col->cut_id; $error_message = $col->cut_error_message; $email_address = $this->get_header_column_value_by_fieldname('email_address', $col, $header_format); $last_name = $this->get_header_column_value_by_fieldname('last_name', $col, $header_format); $first_name = $this->get_header_column_value_by_fieldname('first_name', $col, $header_format); $address1 = $this->get_header_column_value_by_fieldname('address1', $col, $header_format); $city = $this->get_header_column_value_by_fieldname('city', $col, $header_format); $state_code = $this->get_header_column_value_by_fieldname('state_code', $col, $header_format); $zipcode = $this->get_header_column_value_by_fieldname('zipcode', $col, $header_format); $company_id = ''; $company = $this->get_header_column_value_by_fieldname('company', $col, $header_format); if ($company) { $company_id = $ObjCompanies->save_company_if_company_dont_exist($company, $address1, $city, $state_code, $zipcode); } if ($error_message == '') { $last_name = $last_name ? $last_name : 'Department'; $first_name = $first_name ? $first_name : 'Estimating'; $data = array('contact_id_assigned' => $contact_id, 'email_address' => $email_address, 'last_name' => $last_name, 'first_name' => $first_name, 'company_id' => $company_id, 'address1' => $address1, 'city' => $city, 'state_code' => $state_code, 'zipcode' => $zipcode); $cid = $ObjContacts->insert_data($data); if ($cid) { $this->delete_data(array('`cut_id`=' => $cut_id)); } } } } $count_contacts = $this->get_records(array('`cuf_id`=' => $cuf_id)); if ($count_contacts == FALSE) { $result = TRUE; } return $result; }