<?php namespace Config;

class Validation
{
	//--------------------------------------------------------------------
	// Setup
	//--------------------------------------------------------------------

	/**
	 * Stores the classes that contain the
	 * rules that are available.
	 *
	 * @var array
	 */
	public $ruleSets = [
		\CodeIgniter\Validation\Rules::class,
		\CodeIgniter\Validation\FormatRules::class,
		\CodeIgniter\Validation\FileRules::class,
		\CodeIgniter\Validation\CreditCardRules::class,
	];

	/**
	 * Specifies the views that are used to display the
	 * errors.
	 *
	 * @var array
	 */
	public $templates = [
		'list'   => 'CodeIgniter\Validation\Views\list',
		'single' => 'CodeIgniter\Validation\Views\single',
	];

	# S: Hendi
	//--------------------------------------------------------------------
	// Login
	//--------------------------------------------------------------------
	public $login = [
		'user_id' => ['label' => 'Username', 'rules' => 'trim|required'],
		'password' => ['label' => 'Password', 'rules' => 'trim|required']  //|min_length[6]
	];
	public $login_errors = [
		'user_id' => [
			'required' => 'Username harus diisi',
		],
		'password' => [
			'required' => 'Password harus diisi',
			'min_length' => 'Password minimal 6 karakter',
		]
	];
	//--------------------------------------------------------------------
	// Menu
	//--------------------------------------------------------------------
	# created 24 jan 2021
	# is_unique = Checks if this field value exists in the database. 
	# menu = table menu, slug = field slug.
	# Penggunaan is_unique[menu.slug, tag_id, {tag_id}]']
	# bahwa slug harus unik dalam database, 
	# kecuali untuk row yang memiliki tag_id yang cocok dengan nilai {tag_id}. 
	# ini berfungsi untuk edit database
	# jika tidak hanya is_unique[menu.slug], berjalan saat simpan tambah data tapi akan error saat simpan edit data.
	public $menu = [
		'menu_name' => ['label' => 'Nama Menu', 'rules' => 'trim|required|max_length[50]'],
		'slug' => ['label' => 'Slug', 'rules' => 'trim|required|max_length[50]|is_unique[menu.slug, menu_id, {menu_id}]'],  
		'description' => ['label' => 'Keterangan', 'rules' => 'trim|max_length[200]']  
	];
	public $menu_errors = [
		'menu_name' => [
			'required' => 'Nama Menu harus diisi',
			'max_length' => 'Nama Menu maksimal 50 karakter',
		],
		'slug' => [
			'required' => 'Slug harus diisi',
			'max_length' => 'Slug maksimal 50 karakter',
			'is_unique' => 'Menu tersebut sudah digunakan'
		],
		'description' => [
			'required'      => 'Keterangan harus diisi',
			'max_length'    => 'Keterangan maksimal 200 karakter',
		]
	];
	//--------------------------------------------------------------------
	// Antrian
	//--------------------------------------------------------------------
	# created 16 Mar 2021
	# is_unique = Checks if this field value exists in the database. 
	# antrian = table antrian
	# numeric, agar cuma angka saja yg diizinkan 
	public $antrian = [
		'no_antrian' => ['label' => 'No Antrian', 'rules' => 'trim|required|max_length[6]|numeric'],
		'menu_id' => ['label' => 'Menu', 'rules' => 'trim|required|max_length[6]'],
		'qty' => ['label' => 'QTY', 'rules' => 'trim|required|max_length[6]|numeric'],
	];
	public $antrian_errors = [
		'no_antrian' => [
			'required' => 'No Antrian harus diisi',
			'max_length' => 'No Antrian maksimal 6 karakter',
			'numeric' => 'No Antrian tidak valid'
		],
		'menu_id' => [
			'required' => 'Menu harus diisi',
			'max_length' => 'Menu maksimal 6 karakter',
		],
		'qty' => [
			'required' => 'QTY harus diisi',
			'max_length' => 'QTY maksimal 6 karakter',
			'numeric' => 'QTY tidak valid'
		]
	];
	/*
	//--------------------------------------------------------------------
	// Article
	//--------------------------------------------------------------------
	# created 30 jan 2021
	# is_unique = Checks if this field value exists in the database. 
	# article = table article, slug = field slug.
	# Penggunaan is_unique[article.slug, article_id, {article_id}]']
	# bahwa slug harus unik dalam database, 
	# kecuali untuk row yang memiliki article_id yang cocok dengan nilai {article_id}. 
	# ini berfungsi untuk edit database
	# jika tidak hanya is_unique[article.slug], berjalan saat simpan tambah data tapi akan error saat simpan edit data.
	public $article = [
		'title' => ['label' => 'Judul', 'rules' => 'trim|required|max_length[200]'],
		'slug' => ['label' => 'Slug', 'rules' => 'trim|required|max_length[200]|is_unique[article.slug, article_id, {article_id}]']
	];
	public $article_errors = [
		'title' => [
			'required' => 'Judul Artikel harus diisi',
			'max_length' => 'Judul Artikel maksimal 200 karakter',
		],
		'slug' => [
			'required' => 'Slug harus diisi',
			'max_length' => 'Slug maksimal 200 karakter',
			'is_unique' => 'Judul Artikel tersebut sudah digunakan'
		]
	];
	//--------------------------------------------------------------------
	// Page
	//--------------------------------------------------------------------
	# created 2 Feb 2021
	# is_unique = Checks if this field value exists in the database. 
	# page = table page, slug = field slug.
	# Penggunaan is_unique[page.slug, article_id, {article_id}]']
	# bahwa slug harus unik dalam database, 
	# kecuali untuk row yang memiliki article_id yang cocok dengan nilai {article_id}. 
	# ini berfungsi untuk edit database
	# jika tidak hanya is_unique[page.slug], berjalan saat simpan tambah data tapi akan error saat simpan edit data.
	public $page = [
		'title' => ['label' => 'Judul', 'rules' => 'trim|required|max_length[200]'],
		'slug' => ['label' => 'Slug', 'rules' => 'trim|required|max_length[200]|is_unique[page.slug, page_id, {page_id}]']
	];
	public $page_errors = [
		'title' => [
			'required' => 'Judul Halaman harus diisi',
			'max_length' => 'Judul Halaman maksimal 200 karakter',
		],
		'slug' => [
			'required' => 'Slug harus diisi',
			'max_length' => 'Slug maksimal 200 karakter',
			'is_unique' => 'Judul Halaman tersebut sudah digunakan'
		]
	];
	//--------------------------------------------------------------------
	// Article Comment
	//--------------------------------------------------------------------
	# created 9 feb 2021
	public $article_comment = [
		'name' => ['label' => 'Nama', 'rules' => 'trim|required|max_length[50]'],
		'email' => ['label' => 'Email', 'rules' => 'trim|required|max_length[50]|valid_email'],
		'comment' => ['label' => 'Komentar', 'rules' => 'trim|required|max_length[200]']
	];
	public $article_comment_errors = [
		'name' => [
			'required' => 'Nama harus diisi',
			'max_length' => 'Nama maksimal 50 karakter',
		],
		'email' => [
			'required' => 'Email harus diisi',
			'max_length' => 'Email maksimal 50 karakter',
			'valid_email' => 'Email tidak valid',
		],
		'comment' => [
			'required' => 'Komentar harus diisi',
			'max_length' => 'Slug maksimal 200 karakter',
		]
	];
	//--------------------------------------------------------------------
	// User
	//--------------------------------------------------------------------
	# created 11 Feb 2021
	# is_unique = Checks if this field value exists in the database. 
	# m_user = table m_user, user_id = field user_id.
	# Penggunaan is_unique[m_user.user_id, user_id, {user_id}]']
	# bahwa slug harus unik dalam database, 
	# kecuali untuk row yang memiliki user_id yang cocok dengan nilai {user_id}. 
	# ini berfungsi untuk edit database
	# jika tidak hanya is_unique[m_user.user_id], berjalan saat simpan tambah data tapi akan error saat simpan edit data.
	# alpha_numeric, agar cuma huruf dan angka saja yg diizinkan untuk user_id
	public $user = [
		'user_id' => ['label' => 'User ID', 'rules' => 'trim|required|max_length[20]|alpha_numeric'],
		'nama_lengkap' => ['label' => 'Nama Lengkap', 'rules' => 'trim|required|max_length[50]'],
		'kd_level' => ['label' => 'Level', 'rules' => 'trim|required'],
	];
	public $user_errors = [
		'user_id' => [
			'required' => 'User ID harus diisi',
			'max_length' => 'User ID maksimal 20 karakter',
			'alpha_numeric' => 'User ID tidak valid'
		],
		'nama_lengkap' => [
			'required' => 'Nama Lengkap harus diisi',
			'max_length' => 'Nama Lengkap maksimal 50 karakter',
		],
		'kd_level' => [
			'required' => 'Level harus diisi'
		]
	];
	//--------------------------------------------------------------------
	// Ubah Password
	//--------------------------------------------------------------------
	# created 11 feb 2021
	public $change_password = [
		'password' => ['label' => 'Password', 'rules' => 'trim|required|max_length[15]'],
		'new_password' => ['label' => 'Password Baru', 'rules' => 'trim|required|max_length[15]'],
		'confirm_password' => ['label' => 'Konfirmasi Password', 'rules' => 'trim|required|max_length[15]|matches[new_password]']
	];
	public $change_password_errors = [
		'password' => [
			'required' => 'Password Lama harus diisi',
			'max_length' => 'Password Lama maksimal 15 karakter',
		],
		'new_password' => [
			'required' => 'Password Baru harus diisi',
			'max_length' => 'Password Baru maksimal 15 karakter',
		],
		'confirm_password' => [
			'required' => 'Konfirmasi Password harus diisi',
			'max_length' => 'Konfirmasi Password maksimal 15 karakter',
			'matches' => 'Konfirmasi Password tidak sama',
		],
	];
	//--------------------------------------------------------------------
	// Setting Video Siaran langsung
	//--------------------------------------------------------------------
	# created 20 feb 2021
	public $live_streaming = [
		'live_streaming_url' => ['label' => 'URL Video', 'rules' => 'trim|required|max_length[200]'],
	];
	public $live_streaming_errors = [
		'live_streaming_url' => [
			'required' => 'URL Video harus diisi',
			'max_length' => 'URL Video maksimal 200 karakter',
		]
	];
	*/
	# E: Hendi
	//--------------------------------------------------------------------
	// Rules
	//--------------------------------------------------------------------
}
