put spans and divs around paginate_links - html

I wanna style my links and in order to do that I need some spans and divs around it but I dunno how it's done when using paginate_links() from WordPress.
Can you help me to do that?
<div class="pagination">
<?php echo
$pagination = paginate_links( array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'prev_text' => __('← Previous'),
'next_text' => __('Next →'),
'total' => ceil($total / $items_per_page),
'current' => $page,
'type' => 'plain'
));
?>
</div>
so far it looks like that

Just change li to div / span whatever. The main difference is to change your "type" from "plain" to "array" and then you can do what you want with it.
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
$prev_next = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => __('← Previous'),
'next_text' => __('Next →')
) );
if($prev_next){ ?>
<ul>
<?php
foreach($prev_next as $key=>$val){
if (strpos($val,"'page-numbers current'") !== false) {
echo '<li class="active item">'.$val.'</li>';
} elseif (strpos($val,'"next page-numbers"') !== false || strpos($val,'"prev page-numbers"') !== false ) {
echo'<li>'.$val.'</li>';
} else {
echo '<li class="item">'.$val.'</li>';
}
} ?>
</ul>
<?php } ?>

Related

How to Get WooCommerce Product Name with WP_Query?

I am trying to use this code on "Wp All Import". If there is a product name in the database, that product should be omitted, but the code will not work as is. What do I need to do for the code to work?
add_filter('wp_all_import_is_post_to_create', 'create_only_if_unique_custom_field', 10, 3);
function create_only_if_unique_custom_field( $continue_import, $data, $import_id ) {
// Only run for import ID 1.
if ( $import_id == 33 || $import_id == 34 ) {
// The custom field to check.
$key_to_look_up = "post_title";
// The value to check where 'num' is the element name.
$value_to_look_up = $data['name'];
// Prepare the WP_Query arguments
$args = array (
// Set the post type being imported.
'post_type' => array( 'post' ),
// Check our custom field for our value.
'meta_query' => array(array(
'key' => $key_to_look_up,
'value' => $value_to_look_up,
)),
);
// Run the query and do not create post if custom field value is duplicated.
$query = new WP_Query( $args );
return !($query->have_posts());
} else {
// Take no action if a different import ID is running.
return $continue_import;
}
}
You can do like this.
<?php
$params = array('posts_per_page' => 5);
$wc_query = new WP_Query($params);
?>
<?php if ($wc_query->have_posts()) : ?>
<?php while ($wc_query->have_posts()) :
$wc_query->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata();?>
<?php else: ?>
<p>
<?php _e( 'No Products' ); ?>
</p>
<?php endif; ?>
There are some ways to show the different types of Woocommerce product names with WP_Query.
<?php
//Pulling WooCommerce Products instead of WordPress Posts, Use this param
$params = array(
'posts_per_page' => 5,
'post_type' => 'product'
);
//Displaying products of a given price range, use this param
$params = array(
'posts_per_page' => 100,
'post_type' => array('product', 'product_variation'),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_price',
'value' => 5,
'compare' => '<=',
'type' => 'NUMERIC'
),
array(
'key' => '_sales_price',
'value' => 5,
'compare' => '<=',
'type' => 'NUMERIC'
)
)
);
//Displaying available products only, use this param
$params = array(
'posts_per_page' => 5,
'post_type' => array('product', 'product_variation'),
'meta_query' => array(
array(
'key' => '_price',
'value' => 5,
'compare' => '<',
'type' => 'NUMERIC'
),
array(
'key' => '_stock_status',
'value' => 'instock'
)
)
);
$wc_query = new WP_Query($params);
if ($wc_query->have_posts()) :
while ($wc_query->have_posts()) :
$wc_query->the_post();
the_title();
endwhile;
endif;
Also will help you the article https://www.gavick.com/blog/wp_query-woocommerce-products
Thank you
This variable controls the title.
// Xml file column name
$value = = $data['product_title'];
// Get wpdb product title
$posts = get_posts([
'post_type' => 'product',
'title' => $value,
]);

How to use fontawesome in param visual composer?

I code element with visual composer. I want to use fontawesome in element.
Code here show list font-awesome in param visual composer
<code>
array(
'type' => 'iconpicker',
'heading' => esc_html__('Fontawesome', 'interior'),
'param_name' => 'fontawesome_icon',
'settings' => array(
'type' => 'fontawesome'
),
'description' => esc_html__( 'Fontawesome list. Pickup your choice.', 'interior'
),
'dependency' => array(
'element' => 'icon_type',
'value' => array( 'fontawesome-icon' )
)
</code>
I showed list icon in element but i chosen it don't saved and i don't know get value font-awsome display html.
Help me!!!
I have made a code only for Font Awesome Icon... You can try this
below code. it's tested and definitely works. here I have used
"Facebook" in title...Let me know via comment if you found any issue
in code or having any trouble for this.
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if( !class_exists( 'RN_FA_Icon_list' ) ) {
class RN_FA_Icon_list {
private $shortcode;
function __construct() {
/* shortcode base */
$this->shortcode = 'rn_fa_icon_list';
add_action( 'init', array( $this, 'rn_map_shortcode' ) );
add_shortcode( $this->shortcode, array( $this, 'rn_create_shortcode' ) );
}
function rn_map_shortcode( $atts, $content = NULL ) {
if( function_exists( 'vc_map' ) ) {
vc_map(
array(
'name' => esc_html__( 'Font Awesome Icon', 'rn_shortcodes' ),
//'icon' => RN_SHORTCODES_URL . '/admin/img/vc_icons/fancy-list.png',
'base' => $this->shortcode,
'category' => 'Structual',
'class' => 'rn-vc-icon-module rn-structual-module',
'content_element' => true,
'params' => array(
array(
'type' => 'textfield',
'heading' => esc_html__( 'Description', 'rn_shortcodes' ),
'description' => esc_html__( 'Only for internal use. This adds a label to Visual Composer for an easier element identification.', 'rn_shortcodes' ),
'param_name' => 'list_description',
'admin_label' => true,
'group' => 'General'
),
array(
'type' => 'iconpicker',
'heading' => __( 'Icon', 'js_composer' ),
'param_name' => 'icon_fontawesome',
'value' => 'fa fa-adjust',
'group' => 'General',
'settings' => array(
'emptyIcon' => false,
'type' => 'fontawesome',
'iconsPerPage' => 4000,
),
'dependency' => array(
'element' => 'type',
'value' => 'fontawesome',
),
'description' => __( 'Select icon from library.', 'js_composer' ),
),
array(
'type' => 'css_editor',
'param_name' => 'css',
'group' => esc_html__( 'Design Options', 'rn_shortcodes' ),
),
)
)
); /* end mapping */
}
}
function rn_create_shortcode( $atts, $content = NULL ) {
extract( shortcode_atts( array (
'icon_fontawesome' => '',
'css' => ''
), $atts ) );
/* extract list items */
if( function_exists('vc_param_group_parse_atts') && !empty( $values ) ) {
$values = vc_param_group_parse_atts( $values );
}
/* unique listz ID */
$id = uniqid("rn_fa_");
$output = '';
$output .= '<div id="' . esc_attr( $id ) . '">';
$output .= '<i class="' . $icon_fontawesome . '"></i> Facebook';
$output .= '</div>';
return '<div class="wpb_content_element ' . apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class( $css, ' ' ), $this->shortcode, $atts ) . '">' . $output . '</div>';
}
}
}
new RN_FA_Icon_list;
?>

How to get data from multiple dropdown without using submit button

Hi here's my controller
public function actionCreate()
{
$this->layout = "main";
$location = \Yii::$app->getRequest()->getCookies()->getValue( 'location_id' );
if ( $location != NULL )
{
$model = new ScreenTicketBooking();
if ( $model->load( Yii::$app->request->post() ) )
{
return $this->redirect( [ 'time', 'ids' => $model->show_date, 'id' => $model->movie_id ] );
}
else
{
return $this->render( 'create', [
'model' => $model,
] );
}
}
else
{
return $this->redirect( [ 'site/home' ] );
}
}
here's my view
<?php
use app\models\Locations;
use app\models\Movies;
use app\models\MovieShows;
use app\models\ScreenClasses;
use app\models\ScreenClassSeats;
use app\models\Screens;
use app\models\ScreenShowTimes;
use app\models\Theatres;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* #var $this yii\web\View */
/* #var $model app\models\ScreenTicketBooking */
/* #var $form yii\widgets\ActiveForm */
?>
<div class="screen-ticket-booking-form col-md-4">
<?php $form = ActiveForm::begin(); ?>
<?php
$location = \Yii::$app->getRequest()->getCookies()->getValue( 'location_id' );
$movies = MovieShows::find()->where( [ 'location_id' => $location ] )->andWhere( [ '>', 'end_date',
date( 'Y-m-d' ) ] )->all();
if ( $movies != NULL )
{
foreach ( $movies as $movie )
{
$dataCategory[ ] = ArrayHelper::map( Movies::find()->where( 'status=:stat', [ 'stat' => 0 ] )
->andWhere( [ 'id' => $movie->movie_id ] )->all(), 'id',
'movie_name' );
}
}
else
{
$dataCategory = NULL;
}
$newArray = [ ];
if ( $movies != NULL )
{
foreach ( $dataCategory as $array )
{
foreach ( $array as $k => $v )
{
$newArray[ $k ] = $v;
}
}
}
echo $form->field( $model, 'movie_id' )->dropDownList( $newArray,
[ 'prompt' => '-Choose a Movie-',
'onchange' => '
$.get( "' . Url::toRoute( 'screenticketbooking/dependdrop' ) . '", { id: $(this).val() } )
.done(function( data )
{
$( "select#title" ).html( data );
});
' ] )->label( '' ); ?>
<?php $dataPost = ArrayHelper::map( MovieShows::find()
->where( 'movie_id=:mov_id', [ 'mov_id' => $model->movie_id ] )
->asArray()->all(), 'id', 'start_date' );
echo $T = $form->field( $model, 'show_date' )
->dropDownList(
$dataPost,
[ 'id' => 'title', 'prompt' => '-Select a Date-' ]
)->label( '' );
?>
<div class="form-group">
<?=
Html::submitButton( $model->isNewRecord ? Yii::t( 'app', 'OK' ) : Yii::t( 'app', 'Update' ),
[ 'name' => 'submit', 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary',
'id' => 'ajith' ] ) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
both are working flawlessly but now what i want is not to use a submit button and when both dropdowns are selected then automatically get redirected to action Time. i am using a two way dependent dropdown. how can i achieve this ?
Try this.
<?php $dataPost = ArrayHelper::map( MovieShows::find()
->where( 'movie_id=:mov_id', [ 'mov_id' => $model->movie_id ] )
->asArray()->all(), 'id', 'start_date' );
echo $T = $form->field( $model, 'show_date' )
->dropDownList(
$dataPost,
[ 'id' => 'title', 'prompt' => '-Select a Date-', 'onchange' => 'this.form.submit()' ]
)->label( '' );
?>
using this when you select 'show_date' after that submit your form.

WP_Query parameters not working?

So I'm trying to get pagination correct for my wordpress site so categories and pages display the correct posts :
wp_reset_query();
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$sticky = get_option( 'sticky_posts' );
$args = array(
'ignore_sticky_posts' => 1,
'posts_per_page' => 10,
'orderby' => 'date',
'post__not_in' => $sticky,
'paged' => $paged,
);
$query = new WP_Query( $args );
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
I get the posts to display but the following parameters :
'ignore_sticky_posts' => 1,
'posts_per_page' => 10,
'orderby' => 'date',
'post__not_in' => $sticky,
does not seem to work... any idea why ?
Chances are you don't need wp_reset_query() at the top unless you are overriding the global $wp_query somewhere else in your code.
When you are creating a custom query you need to use that throughout your loop. In your case that is $query so we need to use that when calling have_posts(), the_post(), and max_num_pages
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$sticky = get_option( 'sticky_posts' );
$args = array(
'ignore_sticky_posts' => 1,
'posts_per_page' => 10,
'orderby' => 'date',
'post__not_in' => $sticky,
'paged' => $paged,
);
$query = new WP_Query( $args );
?>
<?php if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
// interact with the post here
<?php endwhile; ?>
<?php endif; ?>
// we overwrote the global $post when called the_post(); so we need to reset that
<?php wp_reset_postdata(); ?>
// again we need to reference our custom query for our pagination
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query->max_num_pages
) );
?>

Trigger and form codeigniter

I have a database and form with some trigger in phpmyadmin. When I input the value manually on phpmyadmin, the trigger is executed normally. The problem is, when I input the value by form I made with codeigniter, the trigger is not executed, and there is no error. Can anybody help me?
This is the controller
<?php if (!defined('BASEPATH')) exit ('No direct script access allowed');
class Pengujian extends MY_Controller
{
public $data = array(
'modul' => 'pengujian',
'breadcrumb' => 'Pengujian',
'pesan' => '',
'pagination' => '',
'tabel_data' => '',
'main_view' => 'view_pengujian/pengujian_view',
'form_action' => '',
'form_value' => '',
'option_uji' => '',
);
public function __construct()
{
parent::__construct();
$this->load->model('Pengujian_model', 'pengujian', TRUE);
$this->load->model('Peralatan_model', 'peralatan', TRUE);
$this->load->model('Penerangan_model', 'penerangan', TRUE);
$this->load->model('Kemudi_model', 'kemudi', TRUE);
$this->load->model('Suspensi_model', 'suspensi', TRUE);
$this->load->model('Banpelek_model', 'banpelek', TRUE);
$this->load->model('Rangka_model', 'rangka', TRUE);
$this->load->model('Rem_model', 'rem', TRUE);
$this->load->model('Gasbuang_model', 'gasbuang', TRUE);
$this->load->model('Mesin_model', 'mesin', TRUE);
$this->load->model('Lainlain_model', 'lainlain', TRUE);
$this->load->model('Lainlain2_model', 'lainlain2', TRUE);
$this->load->model('Akhir_model', 'akhir', TRUE);
$this->load->helper('form');
//$this->load->model('Penguji_model', 'penguji', TRUE);
}
public function index($offset = 0)
{
$this->session->unset_userdata('no_pengujian_sekarang', '');
$pengujian = $this->pengujian->cari_semua($offset);
if ($pengujian)
{
$tabel = $this->pengujian->buat_tabel($pengujian);
$this->data['tabel_data'] = $tabel;
$this->data['pagination'] = $this->pengujian->paging(site_url('pengujian/halaman'));
}
else
{
$this->data['pesan'] = 'Tidak ada data pengujian';
}
$this->load->view('template', $this->data);
}
public function tambah1()
{
$this->data['breadcrumb'] = 'Pengujian > Tambah > Awal';
$this->data['main_view'] = 'view_pengujian/pengujian_form';
$this->data['form_action'] = 'pengujian/tambah1';
if($this->input->post('submit'))
{
if($this->pengujian->validasi_tambah())
{
if($this->pengujian->tambah1())
{
$this->session->set_flashdata('pesan', ' Proses tambah data berhasil');
redirect('pengujian/tambah2');
}
else
{
$this->data['pesan'] = 'Proses tambah data gagal';
$this->load->view('template', $this->data);
}
}
else
{
$this->load->view('template', $this->data);
}
}
else
{
$this->load->view('template', $this->data);
}
}
public function tambah2()
{
$this->data['breadcrumb'] = 'Pengujian > Tambah > Peralatan';
$this->data['main_view'] = 'view_pengujian/peralatan_form';
$this->data['form_action'] = 'pengujian/tambah2';
if($this->input->post('submit'))
{
if($this->peralatan->validasi_tambah())
{
if($this->peralatan->tambah2())
{
$this->session->set_flashdata('pesan', ' Proses tambah data berhasil');
redirect('pengujian/tambah3');
}
else
{
$this->data['pesan'] = 'Proses tambah data gagal';
$this->load->view('template', $this->data);
}
}
else
{
$this->load->view('template', $this->data);
}
}
else
{
$this->load->view('template', $this->data);
}
}
I have until tambah12 methods, for each method, it must load from 12 models too, and 12 forms.
This is model
private function load_form_rules_tambah()
{
$form = array(
array(
'field' => 'NO_PENGUJIAN',
'label' => 'no pengujian',
'rules' => 'required'
),
);
return $form;
}
public function validasi_tambah()
{
$form = $this->load_form_rules_tambah();
$this->form_validation->set_rules($form);
if($this->form_validation->run())
{
return TRUE;
}
else
{
return FALSE;
}
}
public function tambah1()
{
$pengujian = array(
'NO_PENGUJIAN' => $this->input->post('NO_PENGUJIAN'),
'NO_PEMERIKSAAN' => $this->input->post('NO_PEMERIKSAAN'),
'LOKASI_PENGUJIAN' => $this->input->post('LOKASI_PENGUJIAN'),
'NO_KODE' => $this->input->post('NO_KODE'),
'NO_KENDARAAN' => $this->input->post('NO_KENDARAAN'),
'PEMILIK_KENDARAAN' => $this->input->post('PEMILIK_KENDARAAN'),
'TYPE_MERK_PABRIK' => $this->input->post('TYPE_MERK_PABRIK'),
'JENIS_KENDARAAN' => $this->input->post('JENIS_KENDARAAN'),
'MULAI_DIPERGUNAKAN' => $this->input->post('MULAI_DIPERGUNAKAN'),
'NO_LAPORAN' => $this->input->post('NO_LAPORAN'),
'JENIS_PEMERIKSAAN' => $this->input->post('JENIS_PEMERIKSAAN'),
'JARAK_PEMAKAIAN' => $this->input->post('JARAK_PEMAKAIAN'),
'BERAT_KENDARAAN' => $this->input->post('BERAT_KENDARAAN'),
'PERALATAN' => $this->input->post('PERALATAN'),
'SISTEM_PENERANGAN' => $this->input->post('SISTEM_PENERANGAN'),
'SISTEM_KEMUDI' => $this->input->post('SISTEM_KEMUDI'),
'AS_DAN_SUSPENSI' => $this->input->post('AS_DAN_SUSPENSI'),
'BAN_DAN_PELEK' => $this->input->post('BAN_DAN_PELEK'),
'RANGKA_DAN_BODI' => $this->input->post('RANGKA_DAN_BODI'),
'SISTEM_REM' => $this->input->post('SISTEM_REM'),
'SISTEM_REM_GAS_BUANG' => $this->input->post('SISTEM_REM_GAS_BUANG'),
'MESIN_TRANSMISI' => $this->input->post('MESIN_TRANSMISI'),
'LAIN_LAIN' => $this->input->post('LAIN_LAIN'),
'LAIN_LAIN2' => $this->input->post('LAIN_LAIN2')
);
//$this->load->library('form_validation');
$this->db->insert($this->db_tabel, $pengujian);
if($this->db->affected_rows() > 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
and this
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Peralatan_model extends CI_Model
{
public $db_tabel ='peralatan';
//public $offset = 0;
//public function cari_semua($offset = 0);
public function tambah2()
{
$peralatan = array(
'NO_CHASIS' => $this->input->post('NO_CHASIS'),
'PLAT_PABRIK_PEMBUAT' => $this->input->post('PLAT_PABRIK_PEMBUAT'),
'PLAT_NOMOR' => $this->input->post('PLAT_NOMOR'),
'TULISAN' => $this->input->post('TULISAN'),
'PENGHAPUS_KACA_DEPAN' => $this->input->post('PENGHAPUS_KACA_DEPAN'),
'KLAKSON' => $this->input->post('KLAKSON'),
'KACA_SPION' => $this->input->post('KACA_SPION'),
'PANDANGAN_KE_DEPAN' => $this->input->post('PANDANGAN_KE_DEPAN'),
'KACA_PENAHAN_SINAR' => $this->input->post('KACA_PENAHAN_SINAR'),
'ALAT_PENGENDALIAN' => $this->input->post('ALAT_PENGENDALIAN'),
'LAMPU_INDIKASI' => $this->input->post('LAMPU_INDIKASI'),
'SPEEDOMETER' => $this->input->post('SPEEDOMETER'),
'PERLENGKAPAN' => $this->input->post('PERLENGKAPAN')
);
//$this->load->library('form_validation');
$this->db->insert($this->db_tabel, $peralatan);
if($this->db->affected_rows() > 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
private function load_form_rules_tambah()
{
$form = array(
array(
'field' => 'NO_PENGUJIAN',
'label' => 'no chasis',
'rules' => 'required'
),
);
return $form;
}
public function validasi_tambah()
{
$form = $this->load_form_rules_tambah();
$this->form_validation->set_rules($form);
if($this->form_validation->run())
{
return TRUE;
}
else
{
return FALSE;
}
}
}
this is the form
<?php
$form = array(
'no pengujian' => array(
'name' => 'NO_PENGUJIAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('NO_PENGUJIAN', isset($form_value['NO_PENGUJIAN']) ? $form_value['NO_PENGUJIAN'] : '')),
'no pemeriksaan' => array(
'name' => 'NO_PEMERIKSAAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('NO_PEMERIKSAAN', isset($form_value['NO_PEMERIKSAAN']) ? $form_value['NO_PEMERIKSAAN'] : '')),
'lokasi pengujian' => array(
'name' => 'LOKASI_PENGUJIAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('LOKASI_PENGUJIAN', isset($form_value['LOKASI_PENGUJIAN']) ? $form_value['LOKASI_PENGUJIAN'] : '')),
'no kode' => array(
'name' => 'NO_KODE',
'size' => '30',
'class' => 'form_field',
'value' => set_value('NO_KODE', isset($form_value['NO_KODE']) ? $form_value['NO_KODE'] : '')),
'no kendaraan' => array(
'name' => 'NO_KENDARAAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('NO_KENDARAAN', isset($form_value['NO_KENDARAAN']) ? $form_value['NO_KENDARAAN'] : '')),
'pemilik kendaraan' => array(
'name' => 'PEMILIK_KENDARAAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('PEMILIK_KENDARAAN', isset($form_value['[PEMILIK_KENDARAAN]']) ? $form_value['PEMILIK_KENDARAAN'] : '')),
'type merk pabrik' => array(
'name' => 'TYPE_MERK_PABRIK',
'size' => '30',
'class' => 'form_field',
'value' => set_value('TYPE_MERK_PABRIK', isset($form_value['TYPE_MERK_PABRIK']) ? $form_value['TYPE_MERK_PABRIK'] : '')),
'jenis kendaraan' => array(
'name' => 'JENIS_KENDARAAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('JENIS_KENDARAAN', isset($form_value['JENIS_KENDARAAN']) ? $form_value['JENIS_KENDARAAN'] : '')),
'mulai dipergunakan' => array(
'name' => 'MULAI_DIPERGUNAKAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('MULAI_DIPERGUNAKAN', isset($form_value['MULAI_DIPERGUNAKAN']) ? $form_value['MULAI_DIPERGUNAKAN'] : '')),
'no laporan' => array(
'name' => 'NO_LAPORAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('NO_LAPORAN', isset($form_value['NO_LAPORAN']) ? $form_value['NO_LAPORAN'] : '')),
'jenis pemeriksaan' => array(
'name' => 'JENIS_PEMERIKSAAN',
'size' => '30',
'class' => 'radio',
'value' => set_value('JENIS_PEMERIKSAAN', isset($_POST['JENIS_PEMERIKSAAN']))),
'jarak pemakaian' => array(
'name' => 'JARAK_PEMAKAIAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('JARAK_PEMAKAIAN', isset($form_value['JARAK_PEMAKAIAN']) ? $form_value['JARAK_PEMAKAIAN'] : '')),
'berat kendaraan' => array(
'name' => 'BERAT_KENDARAAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('BERAT_KENDARAAN', isset($form_value['BERAT_KENDARAAN']) ? $form_value['BERAT_KENDARAAN'] : '')),
'peralatan' => array(
'name' => 'PERALATAN',
'size' => '30',
'value' => set_value('PERALATAN', isset($form_value['PERALATAN']) ? $form_value['PERALATAN'] : '')),
'sistem penerangan' => array(
'name' => 'SISTEM_PENERANGAN',
'size' => '30',
'value' => set_value('SISTEM_PENERANGAN', isset($form_value['SISTEM_PENERANGAN']) ? $form_value['SISTEM_PENERANGAN'] : '')),
'sistem kemudi' => array(
'name' => 'SISTEM_KEMUDI',
'size' => '30',
'value' => set_value('SISTEM_KEMUDI', isset($form_value['SISTEM_KEMUDI']) ? $form_value['SISTEM_KEMUDI'] : '')),
'as dan suspensi' => array(
'name' => 'AS_DAN_SUSPENSI',
'size' => '30',
'value' => set_value('AS_DAN_SUSPENSI', isset($form_value['AS_DAN_SUSPENSI']) ? $form_value['AS_DAN_SUSPENSI'] : '')),
'ban dan pelek' => array(
'name' => 'BAN_DAN_PELEK',
'size' => '30',
'value' => set_value('BAN_DAN_PELEK', isset($form_value['BAN_DAN_PELEK']) ? $form_value['BAN_DAN_PELEK'] : '')),
'rangka dan bodi' => array(
'name' => 'RANGKA_DAN_BODI',
'size' => '30',
'value' => set_value('RANGKA_DAN_BODI', isset($form_value['RANGKA_DAN_BODI']) ? $form_value['RANGKA_DAN_BODI'] : '')),
'sistem rem' => array(
'name' => 'SISTEM_REM',
'size' => '30',
'value' => set_value('SISTEM_REM', isset($form_value['SISTEM_REM']) ? $form_value['SISTEM_REM'] : '')),
'sistem rem gas buang' => array(
'name' => 'SISTEM_REM_GAS_BUANG',
'size' => '30',
'value' => set_value('SISTEM_REM_GAS_BUANG', isset($form_value['SISTEM_REM_GAS_BUANG']) ? $form_value['SISTEM_REM_GAS_BUANG'] : '')),
'mesin transmisi' => array(
'name' => 'MESIN_TRANSMISI',
'size' => '30',
'value' => set_value('MESIN_TRANSMISI', isset($form_value['MESIN_TRANSMISI']) ? $form_value['MESIN_TRANSMISI'] : '')),
'lain lain' => array(
'name' => 'LAIN_LAIN',
'size' => '30',
'value' => set_value('LAIN_LAIN', isset($form_value['LAIN_LAIN']) ? $form_value['LAIN_LAIN'] : '')),
'lain lain2' => array(
'name' => 'LAIN_LAIN2',
'size' => '30',
'value' => set_value('LAIN_LAIN2', isset($form_value['LAIN_LAIN2']) ? $form_value['LAIN_LAIN2'] : '')),
'submit' => array(
'name' => 'submit',
'id' => 'submit',
'value' => 'Simpan'
)
);
?>
<h2><?php echo $breadcrumb ?></h2>
<!-- pesan start -->
<?php if (! empty($pesan)) : ?>
<div class="pesan">
<?php echo $pesan; ?>
</div>
<?php endif ?>
<!-- pesan end -->
<!-- form start -->
<?php echo form_open($form_action); ?>
<p>
<?php echo form_label('No Pengujian', 'NO_PENGUJIAN'); ?>
<?php echo form_input($form['no pengujian']); ?>
</p>
<?php echo form_error('NO_PENGUJIAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('No Pemeriksaan', 'NO_PEMERIKSAAN'); ?>
<?php echo form_input($form['no pemeriksaan']); ?>
</p>
<?php echo form_error('NO_PEMERIKSAAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Lokasi Pengujian', 'LOKASI_PENGUJIAN'); ?>
<?php echo form_input($form['lokasi pengujian']); ?>
</p>
<?php echo form_error('LOKASI_PENGUJIAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('No Kode', 'NO_KODE'); ?>
<?php echo form_input($form['no kode']); ?>
</p>
<?php echo form_error('NO_KODE', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('No Kendaraan', 'NO_KENDARAAN'); ?>
<?php echo form_input($form['no kendaraan']); ?>
</p>
<?php echo form_error('NO_KENDARAAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Pemilik Kendaraan', 'PEMILIK_KENDARAAN'); ?>
<?php echo form_input($form['pemilik kendaraan']); ?>
</p>
<?php echo form_error('PEMILIK_KENDARAAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Type Merk Pabrik', 'TYPE_MERK_PABRIK'); ?>
<?php echo form_input($form['type merk pabrik']); ?>
</p>
<?php echo form_error('TYPE_MERK_PABRIK', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Jenis Kendaraan', 'JENIS_KENDARAAN'); ?>
<?php echo form_input($form['jenis kendaraan']); ?>
</p>
<?php echo form_error('JENIS_KENDARAAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Mulai Dipergunakan', 'MULAI_DIPERGUNAKAN'); ?>
<?php echo form_input($form['mulai dipergunakan']); ?>
</p>
<?php echo form_error('MULAI_DIPERGUNAKAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('No Laporan', 'NO_LAPORAN'); ?>
<?php echo form_input($form['no laporan']); ?>
</p>
<?php echo form_error('NO_LAPORAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Jenis Pemeriksaan', 'JENIS_PEMERIKSAAN'); ?>
<?php echo form_radio('JENIS_PEMERIKSAAN', 'Utama'); ?> Utama
<?php echo form_radio('JENIS_PEMERIKSAAN', 'Ulang'); ?> Ulang
</p>
<p>
<?php echo form_label('Jarak Pemakaian', 'JARAK_PEMAKAIAN'); ?>
<?php echo form_input($form['jarak pemakaian']); ?>
</p>
<?php echo form_error('JARAK_PEMAKAIAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('Berat Kendaraan', 'BERAT_KENDARAAN'); ?>
<?php echo form_input($form['berat kendaraan']); ?>
</p>
<?php echo form_error('BERAT_KENDARAAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_submit($form['submit']); ?>
<?php echo anchor('pengujian', 'Batal', array('class' => 'cancel')) ?>
</p>
<?php echo form_close(); ?>
<?php echo var_dump($form["no pengujian"]); ?>
and this
<?php
$form = array(
'no pengujian' => array(
'name' => 'NO_PENGUJIAN',
'size' => '30',
'class' => 'form_field',
'value' => set_value('NO_PENGUJIAN', isset($form_value['NO_PENGUJIAN']) ? $form_value['NO_PENGUJIAN'] : '')),
'no chasis' => array(
'name' => 'NO_CHASIS',
'size' => '30',
'class' => 'radio',
'value' => set_value('NO_CHASIS', isset($_POST['NO_CHASIS']))),
'plat pabrik pembuat' => array(
'name' => 'PLAT_PABRIK_PEMBUAT',
'size' => '30',
'class' => 'radio',
'value' => set_value('PLAT_PABRIK_PEMBUAT', isset($_POST['PLAT_PABRIK_PEMBUAT']))),
'plat nomor' => array(
'name' => 'PLAT_NOMOR',
'size' => '30',
'class' => 'radio',
'value' => set_value('PLAT_NOMOR', isset($_POST['PLAT_NOMOR']))),
'tulisan' => array(
'name' => 'TULISAN',
'size' => '30',
'class' => 'radio',
'value' => set_value('TULISAN', isset($_POST['TULISAN']))),
'penghapus kaca depan' => array(
'name' => 'PENGHAPUS_KACA_DEPAN',
'size' => '30',
'class' => 'radio',
'value' => set_value('PENGHAPUS_KACA_DEPAN', isset($_POST['PENGHAPUS_KACA_DEPAN']))),
'klakson' => array(
'name' => 'KLAKSON',
'size' => '30',
'class' => 'radio',
'value' => set_value('KLAKSON', isset($_POST['KLAKSON']))),
'kaca spion' => array(
'name' => 'KACA_SPION',
'size' => '30',
'class' => 'radio',
'value' => set_value('KACA_SPION', isset($_POST['KACA_SPION']))),
'pandangan ke depan' => array(
'name' => 'PANDANGAN_KE_DEPAN',
'size' => '30',
'class' => 'radio',
'value' => set_value('PANDANGAN_KE_DEPAN', isset($_POST['PANDANGAN_KE_DEPAN']))),
'kaca penahan sinar' => array(
'name' => 'KACA_PENAHAN_SINAR',
'size' => '30',
'class' => 'radio',
'value' => set_value('KACA_PENAHAN_SINAR', isset($_POST['KACA_PENAHAN_SINAR']))),
'alat pengendalian' => array(
'name' => 'ALAT_PENGENDALIAN',
'size' => '30',
'class' => 'radio',
'value' => set_value('ALAT_PENGENDALIAN', isset($_POST['ALAT_PENGENDALIAN']))),
'lampu indikasi' => array(
'name' => 'LAMPU_INDIKASI',
'size' => '30',
'class' => 'radio',
'value' => set_value('LAMPU_INDIKASI', isset($_POST['LAMPU_INDIKASI']))),
'speedometer' => array(
'name' => 'SPEEDOMETER',
'size' => '30',
'class' => 'radio',
'value' => set_value('SPEEDOMETER', isset($_POST['SPEEDOMETER']))),
'perlengkapan' => array(
'name' => 'PERLENGKAPAN',
'size' => '30',
'class' => 'radio',
'value' => set_value('PERLENGKAPAN', isset($_POST['PERLENGKAPAN']))),
'submit' => array(
'name' => 'submit',
'id' => 'submit',
'value' => 'Simpan'
)
);
?>
<h2><?php echo $breadcrumb ?></h2>
<!-- pesan start -->
<?php if (! empty($pesan)) : ?>
<div class="pesan">
<?php echo $pesan; ?>
</div>
<?php endif ?>
<!-- pesan end -->
<!-- form start -->
<?php echo form_open($form_action); ?>
<p>
<?php echo form_label('No Pengujian', 'NO_PENGUJIAN'); ?>
<?php echo form_input($form['no pengujian']); ?>
</p>
<?php echo form_error('NO_PENGUJIAN', '<p class = "field_error">', '</p>');?>
<p>
<?php echo form_label('No Chasis', 'NO_CHASIS'); ?>
<?php echo form_radio('NO_CHASIS', 'Lulus'); ?> Lulus
<?php echo form_radio('NO_CHASIS', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Plat Pabrik Pembuat', 'PLAT_PABRIK_PEMBUAT'); ?>
<?php echo form_radio('PLAT_PABRIK_PEMBUAT', 'Lulus'); ?> Lulus
<?php echo form_radio('PLAT_PABRIK_PEMBUAT', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Plat Nomor', 'PLAT_NOMOR'); ?>
<?php echo form_radio('PLAT_NOMOR', 'Lulus'); ?> Lulus
<?php echo form_radio('PLAT_NOMOR', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Tulisan', 'TULISAN'); ?>
<?php echo form_radio('TULISAN', 'Lulus'); ?> Lulus
<?php echo form_radio('TULISAN', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Penghapus Kaca Depan', 'PENGHAPUS_KACA_DEPAN'); ?>
<?php echo form_radio('PENGHAPUS_KACA_DEPAN', 'Lulus'); ?> Lulus
<?php echo form_radio('PENGHAPUS_KACA_DEPAN', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Klakson', 'KLAKSON'); ?>
<?php echo form_radio('KLAKSON', 'Lulus'); ?> Lulus
<?php echo form_radio('KLAKSON', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Kaca Spion', 'KACA_SPION'); ?>
<?php echo form_radio('KACA_SPION', 'Lulus'); ?> Lulus
<?php echo form_radio('KACA_SPION', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Pandangan Ke Depan', 'PANDANGAN_KE_DEPAN'); ?>
<?php echo form_radio('PANDANGAN_KE_DEPAN', 'Lulus'); ?> Lulus
<?php echo form_radio('PANDANGAN_KE_DEPAN', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Kaca Penahan Sinar', 'KACA_PENAHAN_SINAR'); ?>
<?php echo form_radio('KACA_PENAHAN_SINAR', 'Lulus'); ?> Lulus
<?php echo form_radio('KACA_PENAHAN_SINAR', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Alat Pengendalian', 'ALAT_PENGENDALIAN'); ?>
<?php echo form_radio('ALAT_PENGENDALIAN', 'Lulus'); ?> Lulus
<?php echo form_radio('ALAT_PENGENDALIAN', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Lampu Indikasi', 'LAMPU_INDIKASI'); ?>
<?php echo form_radio('LAMPU_INDIKASI', 'Lulus'); ?> Lulus
<?php echo form_radio('LAMPU_INDIKASI', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Speedometer', 'SPEEDOMETER'); ?>
<?php echo form_radio('SPEEDOMETER', 'Lulus'); ?> Lulus
<?php echo form_radio('SPEEDOMETER', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_label('Perlengkapan', 'PERLENGKAPAN'); ?>
<?php echo form_radio('PERLENGKAPAN', 'Lulus'); ?> Lulus
<?php echo form_radio('PERLENGKAPAN', 'Gagal'); ?> Gagal
</p>
<p>
<?php echo form_submit($form['submit']); ?>
<?php echo anchor('pengujian', 'Batal', array('class' => 'cancel')) ?>
</p>
<?php echo form_close(); ?>
and this is the trigger form php myadmin
CREATE TRIGGER `trigger_peralatan` BEFORE INSERT ON `peralatan`
FOR EACH ROW begin
if (new.NO_CHASIS = "Lulus"
AND new.PLAT_PABRIK_PEMBUAT = "Lulus"
AND new.PLAT_NOMOR = "Lulus"
AND new.TULISAN = "Lulus"
AND new.PENGHAPUS_KACA_DEPAN = "Lulus"
AND new.KLAKSON = "Lulus"
AND new.KACA_SPION = "Lulus"
AND new.PANDANGAN_KE_DEPAN = "Lulus"
AND new.KACA_PENAHAN_SINAR = "Lulus"
AND new.ALAT_PENGENDALIAN = "Lulus"
AND new.LAMPU_INDIKASI = "Lulus"
AND new.SPEEDOMETER = "Lulus"
AND new.PERLENGKAPAN = "Lulus")
then
UPDATE pengujian
SET PERALATAN = "Lulus"
WHERE NO_PENGUJIAN = new.NO_PENGUJIAN;
else
UPDATE pengujian
SET PERALATAN = "Gagal"
WHERE NO_PENGUJIAN = new.NO_PENGUJIAN; end if;
end
and this for the last trigger
CREATE TRIGGER `trigger_nilai` BEFORE INSERT ON `pengujian`
FOR EACH ROW begin
if
(new.AS_DAN_SUSPENSI = "Lulus" AND
new.BAN_DAN_PELEK = "Lulus" AND
new.LAIN_LAIN = "Lulus" AND
new.LAIN_LAIN2 = "Lulus" AND
new.MESIN_TRANSMISI = "Lulus" AND
new.PERALATAN = "Lulus" AND
new.RANGKA_DAN_BODI = "Lulus" AND
new.SISTEM_KEMUDI = "Lulus" AND
new.SISTEM_PENERANGAN = "Lulus" AND
new.SISTEM_REM = "Lulus" AND
new.SISTEM_REM_GAS_BUANG = "Lulus")
then
SET new.PENILAIAN = "Lulus" ;
else
SET new.PENILAIAN = "Gagal" ; end if;
end
this is the insert query
INSERT INTO `pengujian`(`NO_PENGUJIAN`, `NO_PEMERIKSAAN`, `LOKASI_PENGUJIAN`, `NO_KODE`, `NO_KENDARAAN`, `PEMILIK_KENDARAAN`, `TYPE_MERK_PABRIK`, `JENIS_KENDARAAN`, `MULAI_DIPERGUNAKAN`, `TANGGAL_PEMERIKSAAN`, `NO_LAPORAN`, `JENIS_PEMERIKSAAN`, `JARAK_PEMAKAIAN`, `BERAT_KENDARAAN`, `PERALATAN`, `SISTEM_PENERANGAN`, `SISTEM_KEMUDI`, `AS_DAN_SUSPENSI`, `BAN_DAN_PELEK`, `RANGKA_DAN_BODI`, `SISTEM_REM`, `SISTEM_REM_GAS_BUANG`, `MESIN_TRANSMISI`, `LAIN_LAIN`, `LAIN_LAIN2`, `PENILAIAN`, `TANGGAL_PEMERIKSAAN_BERIKUTNYA`, `CATATAN`, `PENGUJI`, `BIAYA_TOTAL`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5],[value-6],[value-7],[value-8],[value-9],[value-10],[value-11],[value-12],[value-13],[value-14],[value-15],[value-16],[value-17],[value-18],[value-19],[value-20],[value-21],[value-22],[value-23],[value-24],[value-25],[value-26],[value-27],[value-28],[value-29],[value-30])
It's a little confusing...