Commit 3231ff52 by Ashish Pal

Commit template changes and manage file

parent 3ba24b71
.sccuess_message{color:green;font-size: 15px;font-weight: bold;text-align:left;margin: 20px;}
.error_message{color:red;font-size: 15px;font-weight: bold;text-align:left;margin: 20px;}
.note{color:blue;font-size: 15px;font-weight: bold;text-align:left;margin: 20px;}
\ No newline at end of file
......@@ -19,6 +19,7 @@ add_action('admin_init','enqueue_form_plugin_styles');
add_action('admin_init','enqueue_form_plugin_scripts');
function enqueue_form_plugin_styles() {
wp_enqueue_style('datatable-css',PLUGIN_URL.'custody-icici-plugin/css/datatable.min.css' , array(), '1.0.0');
wp_enqueue_style('style',PLUGIN_URL.'custody-icici-plugin/css/style.css' , array(), '1.0.0');
}
function enqueue_form_plugin_scripts(){
wp_enqueue_script('script-js', PLUGIN_URL.'custody-icici-plugin/js/script.js', array('jquery'));
......
......@@ -5,7 +5,7 @@
<tr class="form-field term-name-wrap">
<th scope="row"><label for="name">Type of Form</label></th>
<td>
<select name="type_of_form" id="type_of_form" class="postform required">
<select name="type_of_form" id="type_of_form" class="postform" required>
<option value="">Select Type of Form</option>
<?php
foreach( $result_1 as $value ) { ?>
......@@ -23,7 +23,7 @@
<tr class="form-field term-name-wrap">
<th scope="row"><label for="name">Type of Account</label></th>
<td>
<select name="type_of_account" id="type_of_account" class="postform required">
<select name="type_of_account" id="type_of_account" class="postform" required>
<option value="">Select Type of Account</option>
<?php
foreach( $result as $value ) { ?>
......@@ -41,17 +41,17 @@
<tr class="form-field term-slug-wrap">
<th scope="row"><label for="name">Slug (URL Name)</label></th>
<td>
<input name="slug" id="tag-slug" type="text" value="" size="20">
<input name="slug" id="tag-slug" type="text" value="" size="20" required>
</td>
</tr>
<tr class="form-field term-name-wrap">
<th scope="row"><label for="name">Select File Path</label></th>
<td><input type="text" name="image_url" id="image_url" value=""></a>
<td><input type="text" name="image_url" id="image_url" value="" required></a>
</td>
</tr>
<th scope="row"><label for="name">Ordering</label></th>
<td>
<input name="ordering" id="ordering" type="number" max="100" min="0" size="10" value="<?php echo $ordering?>">
<input name="ordering" id="ordering" type="number" max="100" min="0" size="10" value="<?php echo $ordering?>" required>
</td>
</tr>
<tr class="form-field term-name-wrap">
......
<?php defined( 'ABSPATH' ) or die( 'Direct access is not permitted' );
function check_empty_file($args)
{
$error["status"] = array();
$error["status"] = false;
if(empty($args["type_of_account"]) && empty($args["type_of_form"])){
$error["status"] = true;
$error["error"] = 1;
}elseif(empty($args["type_of_account"])){
$error["status"] = true;
$error["error"] = 2;
}elseif(empty($args["type_of_form"])){
$error["status"] = true;
$error["error"] = 3;
}elseif(empty($args["image_url"])){
$error["status"] = true;
$error["error"] = 4;
}elseif($args["type_of_account"]=='Other' && empty($args["type_of_account_other"]))
{
$error["status"] = true;
$error["error"] = 5;
}
elseif($args["type_of_form"]=='Other' && empty($args["type_of_form_other"]))
{
$error["status"] = true;
$error["error"] = 6;
}
elseif(empty($args["slug"]))
{
$error["status"] = true;
$error["error"] = 7;
}
return $error;
}
function sccuess_message($msg){
$array = array(1=>"Record Added",2=>"Record Updated",3=>"Record Updated",4=>"Updated Type of Form Details",5=>"Updated Type for Account Details");
return $array[$msg];
}
function error_message($msg){
$array = array(1=>"Please select type of account and type of form ",2=>"Please select type of account",3=>"Please select type of form",4=>"Please enter url",5=>"Please fill other type of account details",6=>"Please fill other type of from details",7=>"Please fill slug url namedetails");
return $array[$msg];
}
function check_type_of_account($args)
{
$error["status"] = array();
$error["status"] = false;
if(!empty($args["type_of_account"]) && empty(trim($args["type_of_account_other"]))){
$error["status"] = true;
$error["error"] = 8;
}
return $error;
}
function check_type_of_form($args)
{
$error["status"] = array();
$error["status"] = false;
if(!empty($args["type_of_form"]) && empty(trim($args["type_of_form_other"]))){
$error["status"] = true;
$error["error"] = 8;
}
return $error;
}
?>
\ No newline at end of file
......@@ -7,7 +7,7 @@ $table_name = $wpdb->prefix."custody_icici_forms";
<a href='admin.php?page=custodylist&action=new' class="page-title-action">Add New Forms</a>
<h2>Custody Forms list</h2>
<form class="search-form wp-clearfix" method="get">
<input type="hidden" name="page" value="list">
<input type="hidden" name="page" value="custodylist">
<input type="hidden" name="action" value="search">
<p class="search-box">
<label class="screen-reader-text" for="tag-search-input">Search</label>
......
<?php defined( 'ABSPATH' ) or die( 'Direct access is not permitted' );
$type_of_account = trim($_POST['type_of_account']);
$type_of_form = trim($_POST['type_of_form']);
$slug = trim($_POST['slug']);
$ordering = trim($_POST['ordering']);
$image_url = trim($_POST['image_url']);
if($type_of_form=='Other'){
$type_of_form = trim($_POST['type_of_form_other']);
}
if($type_of_account=='Other'){
$type_of_account = trim($_POST['type_of_account_other']);
}
?>
\ No newline at end of file
<?php defined( 'ABSPATH' ) or die( 'Direct access is not permitted' );?>
<h1 class="wp-heading-inline">Edit Type of Account</h1>
<h3>Note: Please do the activity very carefully in this form, it will update the whole records belonging to selected Type of Account.</h3>
<p class="note">Note: Please do the activity very carefully in this form, it will update the whole records belonging to selected Type of Account.</p>
<table class="form-table">
<form method='post' action='' name='myform' enctype='multipart/form-data'>
<input type="hidden" name="action" id="action" value="update_toa">
......@@ -20,7 +20,7 @@
<tr class="form-field term-name-wrap">
<th scope="row"><label for="name">Enter the Type of Account Value</label></th>
<td>
<input name="type_of_account_other" type="text" value="" size="40" placeholder="Please enter other value">
<input name="type_of_account_other" type="text" value="" size="40" placeholder="Please enter other value" required>
</td>
</tr>
<tr>
......
<?php defined( 'ABSPATH' ) or die( 'Direct access is not permitted' );?>
<h1 class="wp-heading-inline">Edit Type of Form</h1>
<h3>Note: Please do the activity very carefully in this form, it will update the whole records belonging to selected Type of form.</h3>
<p class="note">Note: Please do the activity very carefully in this form, it will update the whole records belonging to selected Type of form.</p>
<table class="form-table">
<form method='post' action='' name='myform' enctype='multipart/form-data'>
<input type="hidden" name="action" id="action" value="update_tof">
......@@ -20,7 +20,7 @@
<tr class="form-field term-name-wrap">
<th scope="row"><label for="name">Enter the Type of Form Value</label></th>
<td>
<input name="type_of_form_other" id="type_of_form_other" type="text" value="" size="40" placeholder="Please enter other value">
<input name="type_of_form_other" id="type_of_form_other" type="text" value="" size="40" placeholder="Please enter other value" required>
</td>
</tr>
<tr>
......
......@@ -2,62 +2,21 @@
defined( 'ABSPATH' ) or die( 'Direct access is not permitted' );
global $wpdb;
$table_name = $wpdb->prefix."custody_icici_forms";
// Upload file
function upload_file($args){
if($args['file']['name'] != ''){
$uploadedfile = $args['file'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
$imageurl = array();
if ($movefile && ! isset( $movefile['error'] ) ) {
$imageurl["url"] = $movefile['url'];
$imageurl["status"] = true;
} else {
$imageurl["status"] = false;
$imageurl["error"] = $movefile['error'];
}
}
return $imageurl;
}
function check_empty_file($args)
{
$error["status"] = array();
$error["status"] = false;
if(empty($args["type_of_account"]) || empty($args["type_of_form"])){
$error["status"] = true;
$error["error"] = "Please select type of account and type of form ";
}
return $error;
}
include_once('includes/functions.php');
if(isset($_POST['but_submit']) && $_POST['but_submit'] == 'Submit'){
if(isset($_POST["image_url"]) && !empty($_POST["image_url"])){
$imageurl["status"] = true;
$imageurl["url"] = $_POST["image_url"];
}
$check_data = check_empty_file($_POST);
if($check_data["status"] || !$imageurl["status"]){
echo "<script>location.replace('admin.php?page=custodylist&error=1');</script>";
}elseif($imageurl["status"]){
$image_url = $imageurl["url"];
$type_of_account = $_POST['type_of_account'];
$type_of_form = $_POST['type_of_form'];
$slug = $_POST['slug'];
$ordering = $_POST['ordering'];
if($type_of_form=='Other'){
$type_of_form = $_POST['type_of_form_other'];
}
if($type_of_account=='Other'){
$type_of_account = $_POST['type_of_account_other'];
}
if($check_data["status"]){
$error = $check_data["error"];
echo "<script>location.replace('admin.php?page=custodylist&err=$error');</script>";
exit();
}else{
include_once('includes/post_variable.php');
$date_time = date('Y-m-d H:i:s');
$data ="INSERT INTO $table_name (type_of_account,type_of_form,slug,download_file_name,created_on,ordering) VALUES('$type_of_account','$type_of_form','$slug','$image_url','$date_time','$ordering')";
$wpdb->query($data);
echo "<script>location.replace('admin.php?page=custodylist&msg=1');</script>";
exit();
}
}
......@@ -81,6 +40,7 @@ if ($_GET['action']=="delete" && isset($_GET['del'])) {
$del_id = $_GET['del'];
$wpdb->query("DELETE FROM $table_name WHERE id='$del_id'");
echo "<script>location.replace('admin.php?page=custodylist');</script>";
exit();
}
if ($_GET['action']=="status" && isset($_GET['upt'])) {
......@@ -88,53 +48,64 @@ if ($_GET['action']=="status" && isset($_GET['upt'])) {
$status = $_GET['status'];
$wpdb->query("update $table_name set status ='$status' WHERE id='$upt'");
echo "<script>location.replace('admin.php?page=custodylist&msg=2');</script>";
exit();
}
if(isset($_POST['but_submit']) && $_POST['but_submit'] == 'Update' && isset($_POST['action'])){
if($_POST['action'] == 'update_main'){
$id = $_POST['id'];
$type_of_account = $_POST['type_of_account'];
$type_of_form = $_POST['type_of_form'];
$slug = $_POST['slug'];
$ordering = $_POST['ordering'];
$imageurl = upload_file($_FILES);
if($imageurl["status"]){
$image_url =$imageurl['url'];
$check_data = check_empty_file($_POST);
if($check_data["status"]){
$error = $check_data["error"];
echo "<script>location.replace('admin.php?page=custodylist&err=$error');</script>";
exit();
}else{
$image_url = $_POST['image_url'];
$id = $_POST['id'];
include_once('includes/post_variable.php');
$update_query = "update $table_name set type_of_account ='$type_of_account',type_of_form ='$type_of_form',slug= '$slug',download_file_name ='$image_url',ordering = '$ordering' WHERE id=".$id;
$wpdb->query($update_query);
echo "<script>location.replace('admin.php?page=custodylist&msg=2');</script>";
exit();
}
$update_query = "update $table_name set type_of_account ='$type_of_account',type_of_form ='$type_of_form',slug= '$slug',download_file_name ='$image_url',ordering = '$ordering' WHERE id=".$id;
$wpdb->query($update_query);
echo "<script>location.replace('admin.php?page=custodylist&msg=1');</script>";
}elseif($_POST['action'] == 'update_tof'){
if($_POST['type_of_form'] && trim($_POST['type_of_form_other'])){
$check_data = check_type_of_form($_POST);
if($check_data["status"]){
$error = $check_data["error"];
echo "<script>location.replace('admin.php?page=custodylist&err=$error');</script>";
exit();
}else{
$type_of_form_other = trim($_POST['type_of_form_other']);
$type_of_form =$_POST['type_of_form'];
$wpdb->query("update $table_name set type_of_form ='$type_of_form_other' WHERE type_of_form='$type_of_form'");
echo "<script>location.replace('admin.php?page=custodylist&msg=4');</script>";
exit();
}
}elseif($_POST['action'] == 'update_toa'){
if($_POST['type_of_account'] && trim($_POST['type_of_account_other'])){
$type_of_account_other = trim($_POST['type_of_account_other']);
$check_data = check_type_of_account($_POST);
if($check_data["status"]){
$error = $check_data["error"];
echo "<script>location.replace('admin.php?page=custodylist&err=$error');</script>";
exit();
}else{
$type_of_account_other = trim($_POST['type_of_account_other']);
$type_of_account =$_POST['type_of_account'];
$wpdb->query("update $table_name set type_of_account ='$type_of_account_other' WHERE type_of_account='$type_of_account'");
echo "<script>location.replace('admin.php?page=custodylist&msg=4');</script>";
echo "<script>location.replace('admin.php?page=custodylist&msg=5');</script>";
exit();
}
}
}
function msg_print($msg){
$array = array(1=>"Record Updated",2=>"Record Updated",3=>"Record Added",4=>"Updated Type for Form Details",5=>"Record Updated");
return $array[$msg];
}
if(isset($_GET['msg'])){
echo msg_print($_GET['msg']);
echo "<br><p class='sccuess_message'>".sccuess_message($_GET['msg'])."</p>";
}
if(isset($_GET['err'])){
echo "<br><p class='error_message'>".error_message($_GET['err'])."</p>";
}
?>
<!-- Form -->
<?php if(isset($_GET['action']) && $_GET['action']=="new"){
include_once('add.php' );
include_once('includes/add.php');
} elseif(isset($_GET['action']) && $_GET['action']=="update"){
$upt_id = $_GET['upt'];
$query ="SELECT * FROM $table_name WHERE id='$upt_id'";
......@@ -182,22 +153,20 @@ if(isset($_GET['msg'])){
<tr class="form-field term-slug-wrap">
<th scope="row"><label for="name">Slug (URL Name)</label></th>
<td>
<input name="slug" id="tag-slug" type="text" value="<?php echo $slug?>" size="40">
<input name="slug" id="tag-slug" type="text" value="<?php echo $slug?>" size="40" required>
</td>
</tr>
<tr class="form-field term-name-wrap">
<th scope="row"><label for="name">Select File Path</label></th>
<td><input type="text" name="image_url" id="image_url" value="<?php echo $download_file_name?>"></a>
<td><input type="text" name="image_url" id="image_url" value="<?php echo $download_file_name?>" required></a>
</td>
</tr>
<tr>
<th scope="row"><label for="name">Ordering</label></th>
<td>
<input name="ordering" id="ordering" type="number" max="100" min="0" size="10" value="<?php echo $ordering?>">
<input name="ordering" id="ordering" type="number" max="100" min="0" size="10" value="<?php echo $ordering?>" required>
</td>
</tr>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='submit' class='button button-primary' name='but_submit' value='Update'></td>
......@@ -217,14 +186,13 @@ if(isset($_GET['msg'])){
$slug = $print->slug;
$ordering = $print->ordering;
}
include_once('view.php');
include_once('includes/view.php');
}elseif(isset($_GET['action']) && $_GET['action']=="ETOF"){
include_once('type_of_form.php');
include_once('includes/type_of_form.php');
}elseif(isset($_GET['action']) && $_GET['action']=="ETOA"){
include_once('type_of_account.php');
include_once('includes/type_of_account.php');
}else{
require_once('listing.php' );
include_once('includes/listing.php' );
}
?>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
......@@ -256,5 +224,4 @@ if(isset($_GET['msg'])){
wp.media.editor.open(button);
return false;
});
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment