public function show_upload_contacts_header($cuf_id)
    {
        $ObjCUF = new contactsUploadedFileModel();
        $rows = $this->get_records(array('`cuf_id`=' => $cuf_id));
        $used_fieldnames_array = $this->get_fieldname_to_array($rows);
        ob_start();
        ?>
		<thead>
			<tr>
		<?php 
        if ($rows) {
            ?>
			<th>
				<div class="checkbox_wrapper">
				<input type="checkbox" name="check_all" value="all" />
				</div>
			</th>
			<?php 
            $n = 1;
            $column_count = count($rows);
            foreach ($rows as $col) {
                $cuff_id = $col->cuff_id;
                $column = $col->cuff_column;
                $name = $col->cuff_name;
                $fieldname = $col->cuff_fieldname;
                $status = $col->cuff_status;
                $edit = $col->cuff_edit;
                $button_wrapper = $this->column_buttons($status, $edit, $cuff_id, $n, $column_count);
                ?>
			<th>
				<div class="column_wrapper column<?php 
                echo $n;
                ?>
 <?php 
                echo $edit;
                ?>
 <?php 
                echo $status;
                ?>
">
					<h5>Column <?php 
                echo $n;
                ?>
</h5>
					<h4 class="name"><?php 
                echo $name ? $name : 'Unnamed';
                ?>
</h4>
					<div class="field_selection">
						<?php 
                if ($status == 'skip' && $edit == 'no') {
                    ?>
						Skipped will not be imported.
						<?php 
                } else {
                    ?>
						<?php 
                    echo $ObjCUF->select_column_name($fieldname, $cuff_id, $used_fieldnames_array, $edit);
                    ?>
						<?php 
                }
                ?>
					</div>
					<div class="button_wrapper">
						<?php 
                echo $button_wrapper;
                ?>
					</div>
					<?php 
                //if( $edit == 'yes' ){
                ?>
					<input type="hidden" name="record_cuff_id" value="<?php 
                echo $cuff_id;
                ?>
" />
					<input type="hidden" name="record_column_no" value="<?php 
                echo $n;
                ?>
" />
					<input type="hidden" name="record_status" value="<?php 
                echo $status;
                ?>
" />
					<input type="hidden" name="record_edit" value="<?php 
                echo $edit;
                ?>
" />
					<input type="hidden" name="record_fieldname" value="<?php 
                echo $fieldname;
                ?>
" />
					<?php 
                //}
                ?>
				</div>
			</th>
			<?php 
                $n++;
            }
        }
        ?>
			</tr>
		</thead>
		<?php 
        $result = ob_get_contents();
        ob_end_clean();
        return $result;
    }
Пример #2
0
 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;
 }