this my code
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
class TransaksiProject extends BaseController {
public function __construct()
{
parent::__construct();
$this->isLoggedIn();
/* Standard Libraries */
$this->load->database();
$this->load->helper('url');
/* ------------------ */
$this->load->library('grocery_CRUD');
}
function index()
{
$this->global['pageTitle'] = 'Cargo Helper : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
function getTransaksiProject()
{
$crud = new grocery_CRUD();
$crud->set_table('tbl_trans_project');
$crud->columns('tnggl_jam','no_barcode','id_company','note','kodepos','id_jenis','total_item','harga','total','total_discount','grand_total','payment_status','created_by','attachment');
$crud->set_field_upload('attachment', 'assets/private');
$crud->unique_fields(array('no_barcode'));
$crud->change_field_type('no_barcode','invisible');
$crud->change_field_type('tnggl_jam','invisible');
$crud->callback_add_field('no_barcode', function () {
return $this->session->userdata("kd_perusahaan")."PR"."-".date("dmy").date("hidys", strtotime("+1 day"));
});
$crud->set_relation('kodepos', 'tbl_harga', 'KODEPOS : {kodepos}, KEL : {kelurahan} KEC: {kecamatan} KAB: {kabupaten} Jenis: {jenis_kiriman} HARGA: {harga}');
$crud->set_primary_key('nm_perusahaan','tbl_company');
$crud->set_relation('id_company', 'tbl_company', 'Perusahaan : {nm_perusahaan}, Alamat : {alamat}');
$crud->set_primary_key('nm_jenis','tbl_jenis');
$crud->set_relation('id_jenis', 'tbl_jenis', 'nm_jenis');
$crud->change_field_type('total','numeric');
$crud->display_as([
'tnggl_jam'=> 'Jam Tanggal Transaksi',
'no_baroce'=> 'No. Transaksi'
]);
$crud->callback_insert(array($this,'insertDataBarcode'));
$output = $crud->render();
$this->global['pageTitle'] = 'Cargo Helper : Data Transaksi Project';
$this->loadViews("transaksiproject", $this->global, $output, NULL);
}
//function _add_default_date_value(){
//$value = !empty($value) ? $value : date("d-M-Y");
// return $value;
// }
/// function getki(){
////$post_array['total'] = $post_array['total_item']*$post_array['harga'];
/// return $post_array;
// }
// function inserttanggal($post_array){
// $post_array['tnggl_jam']= date("Y-m-d h:i:s");
// return $post_array->db->insert('tbl_trans_project',$tnggl);
// }
// function shownobarcode($post_array) {
//$post_array['no_barcode'] = $this->session->userdata("kd_perusahaan")."PR"."-".date("dmy").date("hidys", strtotime("+1 day"));
//$query = $this->db->get_where('tbl_harga',array('id_harga'=>$post_array('harga')));
//return $post_array;
//}
function insertDataBarcode($post_array) {
$post_array['no_barcode']=$this->session->userdata("kd_perusahaan")."PR"."-".date("dmy").date("hidys", strtotime("+1 day"));
$post_array['tnggl_jam']= date("Y-m-d h:i:s");
$post_array['created_by']= $this->session->userdata("userId");
return $this->db->insert('tbl_trans_project',$post_array);
}
}
?>
when add form upload file fail but on edit form they can upload file
can i get suggest?
