hello mariel_alberto ,
here is the code from this function :
skip comments.
public function doc_inc()
{
//$value_i = $this->mymodel->testing();
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('docs');
//$crud->set_relation('doc_type','docs','doc_type');
$crud->columns('date','doc_type','protocol_id','date_ap','sender_rcver','email_s_r','subject','assignment','email_assignment','recipient','recipient_email','sender_id','file_url');
$crud->display_as('date','Hμερ/νία')
->display_as('doc_type','Τύπος Εγγράφου')
->display_as('protocol_id','Αρ.Πρ.')
->display_as('date_ap','Ημερ/νία Απ/λής-Παρ/βής')
->display_as('sender_rcver','Aποστ-Παρ/της')
->display_as('email_s_r','Email')
->display_as('subject','Θέμα')
->display_as('assignment','Ανάθεση')
->display_as('email_assignment','Email Ανάθεσης')
->display_as('recipient','Παραλήπτης Εσωτερικού')
->display_as('recipient_email','Email Παρ/πτη Εσωτερικού')
->display_as('inserted_by','Εισαγωγή από')
->display_as('modified_by','Τροποιήθηκε από')
->display_as('receiver_id','Αρ.Πρωτ.Παραλήπτη')
->display_as('sender_id','Αρ.Πρωτ.Αποστολέα')
->display_as('cc','Κοινοποίηση')
->display_as('email_cc','Email Κοινοποίησης')
->display_as('briefing','Ενημέρωση')
->display_as('briefing_email','Email Ενημέρωσης')
->display_as('doc_status','Κατάσταση Εγγράφου')
->display_as('zip_file_attach','Συμπληρωματικό Επισυναπτόμενο');
$crud->set_subject('docs');
$crud->unset_columns('email_s_r','email_assignment','recipient_email','recipient');
//$crud->fields('date','doc_type','protocol_id','date_ap','sender_rcver','email_s_r','subject','assignment','email_assignment','briefing','briefing_email','recipient','recipient_email','cc','email_cc','sender_id','file_url');
$crud->callback_edit_field('email_assignment', function ($value, $primary_key) {
return '<input type="text" value="'.$value.'" name="email_assignment" placeholder="Αφορά Εισερχόμενο Έγγραφο...">';
});
$crud->callback_edit_field('briefing_email', function ($value, $primary_key) {
return '<input type="text" value="'.$value.'" name="briefing_email" placeholder="Αφορά Εισερχόμενο Έγγραφο...">';
});
$crud->callback_edit_field('email_cc', function ($value, $primary_key) {
return '<input type="text" value="'.$value.'" name="email_cc" placeholder="Αφορά Eξερχόμενο ή Εσωτερικό Έγγραφο...">';
});
$crud->callback_edit_field('recipient_email', function ($value, $primary_key) {
return '<input type="text" value="'.$value.'" name="recipient_email" placeholder="Αφορά Εσωτερικό Έγγραφο...">';
});
$crud->callback_edit_field('sender_id', function ($value, $primary_key) {
return '<input type="text" value="'.$value.'" name="sender_id" placeholder="Αφορά Εισερχόμενο Έγγραφο...">';
});
$crud->callback_edit_field('receiver_id', function ($value, $primary_key) {
return '<input type="text" value="'.$value.'" name="receiver_id" placeholder="Αφορά Εξερχόμενο Έγγραφο...">';
});
$state = $crud->getState();
$info = $crud->getStateInfo();
if ( $state == 'edit'){
$dc = $this->_get_doc_type($info->primary_key);
$this->session->set_userdata('doc_type',$dc);
if ($dc=='Εισερχόμενο'){
if($this->session->userdata('schacUserStatus')=='nocappsadmin' || $this->session->userdata('schacUserStatus')=='eprotocoladmin')
{
$crud->fields('date','doc_type','protocol_id','date_ap','sender_rcver','email_s_r','subject','assignment','email_assignment','briefing','briefing_email','recipient','recipient_email','cc','email_cc','sender_id','receiver_id','file_url','zip_file_attach');
}else {
$crud->unset_edit_fields('cc','email_cc','recipient','recipient_email','receiver_id');
}
}
if ($dc == 'Εξερχόμενο'){
if($this->session->userdata('schacUserStatus')=='nocappsadmin' || $this->session->userdata('schacUserStatus')=='eprotocoladmin'){
$crud->fields('date','doc_type','protocol_id','date_ap','sender_rcver','email_s_r','subject','assignment','email_assignment','briefing','briefing_email','recipient','recipient_email','cc','email_cc','sender_id','receiver_id','file_url','zip_file_attach');
}else{
$crud->unset_edit_fields('briefing','briefing_email','assignment','email_assignment','recipient','recipient_email','sender_id');
}
}
if ($dc == 'Εσωτερικό'){
if($this->session->userdata('schacUserStatus')=='nocappsadmin' || $this->session->userdata('schacUserStatus')=='eprotocoladmin'){
$crud->fields('date','doc_type','protocol_id','date_ap','sender_rcver','email_s_r','subject','assignment','email_assignment','briefing','briefing_email','recipient','recipient_email','cc','email_cc','sender_id','receiver_id','file_url','zip_file_attach');
}else {
$crud->unset_edit_fields('briefing','briefing_email','assignment','email_assignment','date_ap','receiver_id','sender_id');
}
}
$crud->field_type('doc_status','readonly');
$crud->field_type('inserted_by','readonly');
$crud->field_type('modified_by','readonly');
$crud->field_type('folder_file','readonly');
}// end if state
$crud->field_type('doc_type','dropdown',
array('Εισερχόμενο' => 'Εισερχόμενο', 'Εξερχόμενο' => 'Εξερχόμενο','Εσωτερικό' => 'Εσωτερικό'));
/*if ($this->session->userdata('schacUserStatus')!='nocappsadmin'){
$crud->unset_fields('inserted_by');
}*/
$crud->order_by('date','desc');
$crud->callback_after_update(array($this, 'modified_by'));
$crud->callback_column('doc_type',array($this,'_callback_doc_type_highlight'));
$crud->callback_column('assignment',array($this,'_callback_assignment_wrap'));
//$crud->callback_column('protocol_id',array($this,'_callback_protocol_id_wrap'));
$crud->field_type('protocol_id','readonly');
$crud->unset_clone();
$crud->unset_add();
$crud->unset_print();
//$crud->unset_export();
if ($this->session->userdata('schacUserStatus')=='eprotocoluser')
{
$crud->unset_delete();
$crud->unset_edit();
}
if ($this->session->userdata('schacUserStatus') == 'eprotocoladmin'){
$crud->unset_delete();
}
/* resend document */
$crud->add_action('','','main/resendmail','fa fa-envelope-o fa-2x','');
/*$this->db->select('folder_file');
$this->db->where('id', 239);
$q = $this->db->get('docs');
$row = $q->row();*/
//$crud->callback_before_upload(array($this,'get_folder'));
$path = '/assets/uploads/files/'.date('Y');
//if (is_dir($path)) {
if ( $crud->getState() == 'list'){
$crud->callback_column('file_url',array($this,'_callback_upload_file_field'));
$crud->callback_column('zip_file_attach',array($this,'_callback_upload_zip_field'));
//$crud->set_field_upload('file_url','assets/uploads/files/'.date('Y'));
//$crud->set_field_upload('zip_file_attach','assets/uploads/files/'.date('Y'));
}elseif ( $crud->getState() == 'edit') {
$_SESSION['state'] = $crud->getState();
$pkey = $info->primary_key;
$this->db->where('id', $pkey);
$q = $this->db->get('docs');
$r1 = $q->row();
//$_SESSION['p']=$p1;
$crud->set_field_upload('file_url','assets/uploads/files/'.date('Y'));
//$crud->set_field_upload('file_url','assets/uploads/files/'.$r1->folder_file);
//$crud->set_field_upload('file_url','assets/uploads/files/2021');
//$crud->set_field_upload('file_url',$this->verify_path_callback($path));
$crud->set_field_upload('zip_file_attach','assets/uploads/files/'.date('Y'));
//$crud->set_field_upload('zip_file_attach','assets/uploads/files/2021');
//$crud->set_field_upload('zip_file_attach','assets/uploads/files/'.$r1->folder_file);
//$crud->callback_before_upload(array($this,'_callback_before_upload'));
}else {
$_SESSION['state'] = $crud->getState();
$pkey = $info->primary_key;
$this->db->where('id', $pkey);
$q = $this->db->get('docs');
$row = $q->row();
//$_SESSION['zip_file_attach'] = $row->folder_file;
//$crud->set_field_upload('file_url','assets/uploads/files/'.$row->folder_file);
//$crud->set_field_upload('file_url','assets/uploads/files/2021');
$crud->set_field_upload('file_url','assets/uploads/files/'.date('Y'));
//$crud->set_field_upload('file_url',$this->verify_path_callback($path));
//$crud->set_field_upload('zip_file_attach','assets/uploads/files/'.$row->folder_file);
$crud->set_field_upload('zip_file_attach','assets/uploads/files/'.date('Y'));
//$crud->callback_before_upload(array($this,'_callback_before_upload'));
//$crud->set_field_upload('zip_file_attach','assets/uploads/files/'.date('Y'));
}
//}
//$crud->add_action('Project_Details', '', '','ui-icon-plus',array($this,'get_id'));
//$crud->add_action('Project_Details', '', 'examples/proj_details','ui-icon-plus');
$output = $crud->render();
if ( $this->session->userdata('is_authenticated') ){
$this->_example_output($output);
}else {
redirect('Main');
}
}