<commit_before><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Document extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->ctl = "Document";
		$this->load->model('mdl_document');
		$now = new DateTime(null, new DateTimeZone('Asia/Bangkok'));
		$this->dt_now = $now->format('Y-m-d H:i:s');
		$this->datenow = $now->format('d/m/').($now->format('Y')+543);
	}

	public function index()
	{
		$TEXTTITLE = "<i class=\"fa fa-fw fa-folder\"></i>ระบบจัดเก็บเอกสาร งานวิจัย";
		// $PAGE = 'Document/indexDoc';
		$PAGE = 'Document/index';
		$this->data['getAllDoc'] = $this->mdl_document->getAllDoc();
		$this->mainpage($TEXTTITLE);
		$this->load->view($PAGE,$this->data);
	}

	public function mainpage($TEXTTITLE)
	{
		$this->data['header'] = $this->template->getHeader(base_url(),$TEXTTITLE);
		$this->data['footer'] = $this->template->getFooter(base_url());
		$this->data['controller'] = $this->ctl;
		$this->data["datenow"] =$this->datenow;
		$this->data['url_add']    = base_url().$this->ctl.'/formCreate/';
		$this->data['url_update']   = base_url().$this->ctl.'/formUpdate/';
	}

	public function test()
	{
		$TEXTTITLE = "เพิ่มงานวิจัย";
		$PAGENAME  = "formCreate";
		$this->mainpage($TEXTTITLE);
		$this->load->view('/Document/'.$PAGENAME,$this->data);
	}

	public function formCreate()
	{
		$TEXTTITLE = "เพิ่มงานวิจัย";
		$PAGENAME  = "formCreate";
		$this->data["datenow"] =$this->datenow;
		$this->mainpage($TEXTTITLE);
		$this->load->view('/Document/'.$PAGENAME,$this->data);
	}

	public function createDoc()
	{

		$Outline = ($_FILES['Outline'] != "")?$this->_upload_files('Outline'):'';
		$Progress = ($_FILES['Progress'] != "")?$this->_upload_files('Progress'):'';
		$Success = ($_FILES['Success'] != "")?$this->_upload_files('Success'):'';

		$data = array(
			'doc_name' => $this->input->post('name'),
			'doc_lastname' => $this->input->post('lastname'),
			'doc_moneySupport' => $this->input->post('moneySupport'),
			'doc_amount' => $this->input->post('amount'),
			'doc_publicationWhere' => $this->input->post('publicationWhere'),
			'doc_researchName' => str_replace("\n", "<br>",$this->input->post('researchName')),
			'doc_abstract' => str_replace("\n", "<br>",$this->input->post('abstract')),
			'doc_outline' => $Outline['file_name'],
			'doc_progress' => $Progress['file_name'],
			'doc_filesuccess' => $Success['file_name'],
			'dt_create' => $this->dt_now,
			'ip_create' => $_SERVER['REMOTE_ADDR'],
			);
		$this->mdl_document->insertDoc($data);
		redirect('Document','refresh');
	}

	public function formUpdate($idDoc)
	{
		$TEXTTITLE = "อัพเดทเอกสาร";
		$PAGENAME = "formUpdate";
		$this->data['dataDoc'] = $this->mdl_document->getDocID($idDoc);
		$this->mainpage($TEXTTITLE);
		$this->load->view('/Document/'.$PAGENAME,$this->data);
	}

	public function saveUpdate()
	{
		$docID = $this->input->post('doc_id');
		// $Outline = $_FILES['Outline'];
		// if($Outline !=""){$Outline = 	$this->_upload_files('Outline');$this->deleteFile($docID,"doc_outline");	echo "1";
		// }else{	echo "2";	$Outline ="";		}
		$Outline = ($_FILES['Outline'] != "")?$this->upFile($docID,'doc_outline','Outline'):'';
		$Progress = ($_FILES['Progress'] != "")?$this->_upload_files('Progress'):'';
		$Success = ($_FILES['Success'] != "")?$this->_upload_files('Success'):'';

		$data = array(
			'doc_name' => $this->input->post('name'),
			'doc_lastname' => $this->input->post('lastname'),
			'doc_moneySupport' => $this->input->post('moneySupport'),
			'doc_amount' => $this->input->post('amount'),
			'doc_publicationWhere' => $this->input->post('publicationWhere'),
			'doc_researchName' => str_replace("\n", "<br>",$this->input->post('researchName')),
			'doc_abstract' => str_replace("\n", "<br>",$this->input->post('abstract')),
			'doc_outline' => $Outline['file_name'],
			'doc_progress' => $Progress['file_name'],
			'doc_filesuccess' => $Success['file_name'],
			'dt_create' => $this->dt_now,
			'ip_create' => $_SERVER['REMOTE_ADDR'],
			);
		// echo "<pre>";
		$this->db->where('doc_id',$docID);
		$this->db->update('document',$data);
		var_dump($Outline);
	}<commit_msg>update Document file<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Document extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->ctl = "Document";
		$this->load->model('mdl_document');
		$now = new DateTime(null, new DateTimeZone('Asia/Bangkok'));
		$this->dt_now = $now->format('Y-m-d H:i:s');
		$this->datenow = $now->format('d/m/').($now->format('Y')+543);
	}

	public function index()
	{
		$TEXTTITLE = "<i class=\"fa fa-fw fa-folder\"></i>ระบบจัดเก็บเอกสาร งานวิจัย";
		// $PAGE = 'Document/indexDoc';
		$PAGE = 'Document/index';
		$this->data['getAllDoc'] = $this->mdl_document->getAllDoc();
		$this->mainpage($TEXTTITLE);
		$this->load->view($PAGE,$this->data);
	}

	public function mainpage($TEXTTITLE)
	{
		$this->data['header'] = $this->template->getHeader(base_url(),$TEXTTITLE);
		$this->data['footer'] = $this->template->getFooter(base_url());
		$this->data['controller'] = $this->ctl;
		$this->data["datenow"] =$this->datenow;
		$this->data['url_add']    = base_url().$this->ctl.'/formCreate/';
		$this->data['url_update']   = base_url().$this->ctl.'/formUpdate/';
	}

	public function test()
	{
		$TEXTTITLE = "เพิ่มงานวิจัย";
		$PAGENAME  = "formCreate";
		$this->mainpage($TEXTTITLE);
		$this->load->view('/Document/'.$PAGENAME,$this->data);
	}

	public function formCreate()
	{
		$TEXTTITLE = "เพิ่มงานวิจัย";
		$PAGENAME  = "formCreate";
		$this->data["datenow"] =$this->datenow;
		$this->mainpage($TEXTTITLE);
		$this->load->view('/Document/'.$PAGENAME,$this->data);
	}

	public function createDoc()
	{

		$Outline = ($_FILES['Outline'] != "")?$this->_upload_files('Outline'):'';
		$Progress = ($_FILES['Progress'] != "")?$this->_upload_files('Progress'):'';
		$Success = ($_FILES['Success'] != "")?$this->_upload_files('Success'):'';

		$data = array(
			'doc_name' => $this->input->post('name'),
			'doc_lastname' => $this->input->post('lastname'),
			'doc_moneySupport' => $this->input->post('moneySupport'),
			'doc_amount' => $this->input->post('amount'),
			'doc_publicationWhere' => $this->input->post('publicationWhere'),
			'doc_researchName' => str_replace("\n", "<br>",$this->input->post('researchName')),
			'doc_abstract' => str_replace("\n", "<br>",$this->input->post('abstract')),
			'doc_outline' => $Outline['file_name'],
			'doc_progress' => $Progress['file_name'],
			'doc_filesuccess' => $Success['file_name'],
			'dt_create' => $this->dt_now,
			'ip_create' => $_SERVER['REMOTE_ADDR'],
			);
		$this->mdl_document->insertDoc($data);
		redirect('Document','refresh');
	}

	public function formUpdate($idDoc)
	{
		$TEXTTITLE = "อัพเดทเอกสาร";
		$PAGENAME = "formUpdate";
		$this->data['dataDoc'] = $this->mdl_document->getDocID($idDoc);
		$this->mainpage($TEXTTITLE);
		$this->load->view('/Document/'.$PAGENAME,$this->data);
	}

	public function saveUpdate()
	{
		$docID = $this->input->post('doc_id');
		// $Outline = $_FILES['Outline'];
		// if($Outline !=""){$Outline = 	$this->_upload_files('Outline');$this->deleteFile($docID,"doc_outline");	echo "1";
		// }else{	echo "2";	$Outline ="";		}
		$Outline = ($_FILES['Outline'] != "")?$this->upFile($docID,'doc_outline','Outline'):'';
		$Progress = ($_FILES['Progress'] != "")?$this->upFile($docID,'doc_progress','Progress'):'';
		$Success = ($_FILES['Success'] != "")?$this->upFile($docID,'doc_filesuccess','Success')'Success'):'';

		$data = array(
			'doc_name' => $this->input->post('name'),
			'doc_lastname' => $this->input->post('lastname'),
			'doc_moneySupport' => $this->input->post('moneySupport'),
			'doc_amount' => $this->input->post('amount'),
			'doc_publicationWhere' => $this->input->post('publicationWhere'),
			'doc_researchName' => str_replace("\n", "<br>",$this->input->post('researchName')),
			'doc_abstract' => str_replace("\n", "<br>",$this->input->post('abstract')),
			'doc_outline' => $Outline['file_name'],
			'doc_progress' => $Progress['file_name'],
			'doc_filesuccess' => $Success['file_name'],
			'dt_create' => $this->dt_now,
			'ip_create' => $_SERVER['REMOTE_ADDR'],
			);
		// echo "<pre>";
		$this->db->where('doc_id',$docID);
		$this->db->update('document',$data);
		var_dump($Outline);
	}
{'fraction_non_alphanumeric': 0.2552045944005743, 'fraction_numerical': 0.0011964584828906438, 'mean_word_length': 5.545810493343774, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 249, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5199166', 'n_tokens_mistral': 3436, 'n_tokens_neox': 3148, 'n_words': 386}