codeigniter show attachment image in body email - codeigniter

so i want to send an email html template using codeigniter.
in that template, i want to embed some images. i already tried to send image as attachment and success, the problem is, i couldn't show the attached images to my html body template.
this is the controller`
class sendMails extends CI_Controller {
public function htmlmail(){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'email',
'smtp_pass' => 'pass',
'smtp_timeout' => '4',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('enmail', 'name');
//$data = array(
//'userName'=> 'uname'
// );
$userEmail = "email";
$subject = "testing email";
$this->email->to($userEmail); // replace it with receiver mail id
$this->email->subject($subject); // replace it with relevant subject
$logo = $this->email->attach('images/logo.jpg', 'inline');
$menuApp = $this->email->attach('images/menuApp.jpg','inline');
$tengah2 = $this->email->attach('images/tengah2.jpg','inline');
$cid = $this->email->attachment_cid($logo);
$cids = $this->email->attachment_cid($menuApp);
$cidss = $this->email->attachment_cid($tengah2);
//$body = $this->load->view('emails/emailAlfamind.php','',TRUE);
//$this->email->message($body);
//$this->email->send();
$message = '<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/html; charset="utf-8"><title></title></head><body>';
$message .= '<table align="left" border="0" cellpadding="0" cellspacing="0" width="774" style="border-collapse: collapse; border:none">';
$message .= ' <tr>';
$message .= ' <td width="780" height="30px" align="center" bgcolor="#ED0A28"> <font color="#FFFFFF" style="font-family:Arial, Helvetica, sans-serif" size="-1" > <b> Customer Service ALFAMIND: (021) 1500 959 </b></font><!--<img src="http://i.imgur.com/pM5yp5l.jpg" width="800" height="100%" pointer-events:"none"/>--></td>';
$message .= ' </tr>';
$message .= ' <tr>';
$message .= ' <td bgcolor="#E6E7E9" align="center" ;><br/> <img src= cid:"$cid" alt="logo" /> <br/><p></p></td>';
$message .= ' </tr>';
$message .= ' <tr>';
$message .= ' <td bgcolor="#E6E7E9">';
$message .= ' <table align="center" width="735" bgcolor="#FFFFFF" border="0">';
$message .= ' <tr>';
$message .= ' <td> ';
$message .= ' asdasd';
$message .= ' </td>';
$message .= ' </tr>';
$message .= ' </table>';
$message .= ' </td>';
$message .= '</tr>';
$message .= '<tr>';
$message .= ' <td bgcolor="#E6E7E9" >';
$message .= ' <table align="center" border="0" height="75px" bgcolor="#E6E7E9" >';
$message .= ' <tr>';
$message .= ' <td width="10"> ';
$message .= ' </td>';
$message .= ' <td width="472">';
$message .= ' <table align="center" border="0" height="75px" width="468" bgcolor="#E6E7E9">';
$message .= ' <tr>';
$message .= ' <td colspan="3">';
$message .= ' <font color="#181818" style="font-family:Arial, Helvetica, sans-serif" size="2" > ';
$message .= ' Jika anda memiliki pertanyaan lebih lanjut, silakan hubungi kami melalui:';
$message .= ' </font>';
$message .= ' </td>';
$message .= ' </tr>';
$message .= ' <tr>';
$message .= ' <td width="166">';
$message .= ' <font color="#575757" style="font-family:Arial, Helvetica, sans-serif" size="2" > ';
$message .= ' <b>';
$message .= ' E-mail: email';
$message .= ' <br/>';
$message .= ' SMS Center: num';
$message .= ' </b>';
$message .= ' </font>';
$message .= ' </td>';
$message .= ' <td width="32">';
$message .= ' <img src= cid:"$cids" alt="logo" " width="31" height="55"/>';
$message .= ' </td>';
$message .= ' <td width="260">';
$message .= ' <font color="#575757" style="font-family:Arial, Helvetica, sans-serif" size="2" > ';
$message .= ' <b>';
$message .= ' PT. Sumber Alfaria Trijaya Tbk.';
$message .= ' <br/>';
$message .= ' Jl. M.H. Thamrin No.9, Cikokol, Tangerang';
$message .= ' </b>';
$message .= ' </font>';
$message .= ' </td>';
$message .= ' </tr>';
$message .= ' </table>';
$message .= ' </td>';
$message .= ' <td width="270" ><img src= cid:"$cidss" alt="logo" " width="263" height="100"/></td>';
$message .= ' </tr>';
$message .= ' </table>';
$message .= ' </td>';
$message .= ' </tr>';
$message .= ' <tr>';
$message .= ' <td bgcolor="#ED0A28" height="30px" align="center"> <font color="#FFFFFF" style="font-family:Arial, Helvetica, sans-serif" size="-1" > Copyright © 2016 ALFAMIND. All rights reserved. </font>';
$message .= ' </tr>';
$message .= ' </table>';
$message .= '</body></html>';
//$this->email->message("<img src='cid:". $cid ."' alt='photo1' />");
$this->email->message($message);
if(!$this->email->send())
{
echo "gagal";
}else{
echo "sukses";
}
}
}`
as you can se, i already tried to call the image using the part but it doesn't work
could you give me a solution for my problem? thank you

Try:
$filename = '/img/photo1.jpg';
$this->email->attach($filename);
foreach ($list as $address)
{
$this->email->to($address);
$cid = $this->email->attachment_cid($filename);
$this->email->message('<img src='cid:". $cid ."' alt="photo1" />');
$this->email->send();
}
Documenttation:
CodeIgniter Documentation

Related

Magento configuration product to custom laravel configurable product using ajax

Currently I am trying to convert Magento Configurable product to Custom Laravel configurable product.
In step one I am displaying all the attributes from backend
Step 1: Select Attributes
(Here I have displayed all the attributes from backend)
My view blade code:
<div class="container">
<div class="row p-b-35">
<div class="form-group">
#foreach($attributes as $attribute)
<div class="form-check complete">
<input type="checkbox" id="{{$attribute->id}}" name="attribute[]" value="{{$attribute->id}}">
<label for="{{$attribute->id}}">
{{$attribute->name}}
</label>
</div>
#endforeach
</div>
</div>
<button class="btn btn-cons btn-primary" id="stepOne">Next</button>
</div>
Once the user check the attribute I have use ajax to store the attribute id
Ajax code:
$('#stepOne').click(function(e){
e.preventDefault();
var attribute = "";
$(":checkbox").each(function () {
var ischecked = $(this).is(":checked");
if (ischecked) {
attribute += $(this).val() + ",";
}
});
$.ajax({
url: "/configStepOne",
type:"POST",
data:{
"_token": "{{ csrf_token() }}",
attribute:attribute,
},
success:function(response){
$('#successMsg').show();
$('#stepOneResponse').append(response.html);
},
error: function(response) {
console.log(response.responseJSON.message);
},
});
});
In my controller method (configStepOne):
public function configStepOne(Request $request) {
if (!is_null(Session::get('attributes'))) {
Session::forget('attributes');
}
Session::put('attributes', $request->attribute);
$config_attribute_array = [];
if (!is_null(Session::get('attributes'))) {
$config_attribute = Session::get('attributes');
$config_attribute = substr($config_attribute, 0, -1);
$config_attribute_array = explode(',', $config_attribute);
}
$html = "";
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$html .= '<p class="small hint-text m-b-20">'.$config_attr->name.'</p>';
foreach($config_attr->options as $option) {
$html .= '<div class="form-check complete">';
$html .= '<input type="checkbox" id="'.$config_attr->name. '-' .$option->id.'-'.$option->option.'" name="option[]" value="'.$option->id.'">';
$html .= '<label for="'.$config_attr->name.'-'.$option->id.'-'.$option->option.'">'.$option->option.'</label>';
$html .= '</div>';
}
$html .= '<br>';
}
return response()->json(['success'=>'Successfully', 'html' => $html]);
}
Here I am trying to get the attributes respective options from backend and append the response to blade view
Step 2: Attribute Values
In my blade view I have:
<div id="stepOneResponse">
</div>
<button class="btn btn-cons btn-primary" id="stepTwo">Next</button>
From Ajax append the blade view is updated as:
<div id="stepOneResponse">
<p class="small hint-text m-b-20">Color</p>
<div class="form-check complete"><input type="checkbox" id="Color-1-Red" name="option[]" value="1"><label for="Color-1-Red">Red</label></div>
<div class="form-check complete"><input type="checkbox" id="Color-2-Black" name="option[]" value="2"><label for="Color-2-Black">Black</label></div>
<div class="form-check complete"><input type="checkbox" id="Color-7-Blue" name="option[]" value="7"><label for="Color-7-Blue">Blue</label></div>
<div class="form-check complete"><input type="checkbox" id="Color-8-Green" name="option[]" value="8"><label for="Color-8-Green">Green</label></div>
<br>
<p class="small hint-text m-b-20">Size</p>
<div class="form-check complete"><input type="checkbox" id="Size-3-XL" name="option[]" value="3"><label for="Size-3-XL">XL</label></div>
<div class="form-check complete"><input type="checkbox" id="Size-4-SM" name="option[]" value="4"><label for="Size-4-SM">SM</label></div>
<div class="form-check complete"><input type="checkbox" id="Size-9-medium" name="option[]" value="9"><label for="Size-9-medium">medium</label></div>
<div class="form-check complete"><input type="checkbox" id="Size-10-Extra small" name="option[]" value="10"><label for="Size-10-Extra small">Extra small</label></div>
<br>
<p class="small hint-text m-b-20">Format</p>
<div class="form-check complete"><input type="checkbox" id="Format-13-Download" name="option[]" value="13"><label for="Format-13-Download">Download</label></div>
<div class="form-check complete"><input type="checkbox" id="Format-14-DVD" name="option[]" value="14"><label for="Format-14-DVD">DVD</label></div>
<br>
</div>
<button class="btn btn-cons btn-primary" id="stepTwo">Next</button>
Ajax code:
$('#stepTwo').click(function(e){
e.preventDefault();
var option = "";
var option_id = "";
$("#stepOneResponse :checkbox").each(function () {
var ischecked = $(this).is(":checked");
if (ischecked) {
option += $(this).val() + ",";
option_id += $(this).attr('id') + ",";
}
});
$.ajax({
url: "/configStepTwo",
type:"POST",
data:{
"_token": "{{ csrf_token() }}",
option:option,
option_id:option_id,
},
success:function(response){
$('#successMsg').show();
console.log(response);
$('#stepTwoImageResponse').append(response.imageHtml);
$('#stepTwoPriceResponse').append(response.priceHtml);
$('#stepTwoQtyResponse').append(response.qtyHtml);
$('#count').text(response.count);
},
error: function(response) {
console.log(response.responseJSON.message);
},
});
});
In controller method configStepTwo:
public function configStepTwo(Request $request) {
if (!is_null(Session::get('options'))) {
// Session::forget('option');
}
Session::put('options', $request->option);
Session::put('options_id', $request->option_id);
$config_attribute = "";
$config_attribute_opt_string = "";
$config_attribute_array = [];
$config_attribute_opt_array = [];
$config_attribute_opt_array_id = [];
if (!is_null(Session::get('attributes'))) {
$config_attribute = Session::get('attributes');
$config_attribute = substr($config_attribute, 0, -1);
$config_attribute_array = explode(',', $config_attribute);
// dd($config_attribute_array);
}
if (!is_null(Session::get('options'))) {
$config_attribute_opt = Session::get('options');
$config_attribute_opt = substr($config_attribute_opt, 0, -1);
$config_attribute_opt_array = explode(',', $config_attribute_opt);
// dd($config_attribute_opt_array);
}
if (!is_null(Session::get('options_id'))) {
$config_attribute_opt_id = Session::get('options_id');
// $config_attribute_opt_id = strstr($config_attribute_opt_id, '-', true);
$config_attribute_opt_id = substr($config_attribute_opt_id, 0, -1);
$config_attribute_opt_array_id = explode(',', $config_attribute_opt_id);
}
foreach ($config_attribute_opt_array_id as $key => $value) {
$config_attribute_opt_string .= strstr($value, '-', true). ',';
// $config_attribute_opt_string .= $value. ',';
}
$config_attribute_opt_string = substr($config_attribute_opt_string, 0, -1);
$config_attribute_opt_array_id = explode(',', $config_attribute_opt_string);
$array_count = array_count_values($config_attribute_opt_array_id);
$count = 1;
foreach ($array_count as $key => $value) {
$count *= $value;
}
Session::put('count', $count);
$imageHtml = "";
$imageHtml .= '<div class="form-group col-lg-4" id="multi_config_image" style="display: none">
<label for="type">Select attribute </label>
<select name="image_attribute_id" class="form-control" id="image_attribute_id">
<option value="">Select</option>';
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$imageHtml .= '<option value="'.$config_attr->name.'">'.$config_attr->name.'</option>';
}
$imageHtml .= '</select>';
foreach($config_attribute_opt_array as $value) {
$config_opt = AttributeOption::findOrFail($value);
$imageHtml .= '<div id="image_option_id">';
$imageHtml .= '<div class="row '.$config_opt->attribute->name.'" style="display: none;">'. $config_opt->option.'<input type="file" name="option_image" class="form-control" >';
$imageHtml .= '</div>';
$imageHtml .= '</div>';
}
$imageHtml .= '</div>';
$priceHtml = "";
$priceHtml .= '<div class="form-group col-lg-4" id="multi_config_price" style="display: none">
<label for="type">Select attribute </label>
<select name="price_attribute_id" class="form-control" id="price_attribute_id">
<option value="">Select</option>';
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$priceHtml .= '<option value="'.$config_attr->name.'">'.$config_attr->name.'</option>';
}
$priceHtml .= '</select>';
foreach($config_attribute_opt_array as $value) {
$config_opt = AttributeOption::findOrFail($value);
$priceHtml .= '<div id="price_option_id">';
$priceHtml .= '<div class="row '.$config_opt->attribute->name.'" style="display: none;">'. $config_opt->option.'<input type="text" name="option_price[]" class="form-control" >';
$priceHtml .= '</div>';
$priceHtml .= '</div>';
}
$priceHtml .= '</div>';
$qtyHtml = "";
$qtyHtml .= '<div class="form-group col-lg-4" id="multi_config_qty" style="display: none">
<label for="type">Select attribute </label>
<select name="qty_attribute_id" class="form-control" id="qty_attribute_id">
<option value="">Select</option>';
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$qtyHtml .= '<option value="'.$config_attr->name.'">'.$config_attr->name.'</option>';
}
$qtyHtml .= '</select>';
foreach($config_attribute_opt_array as $value) {
$config_opt = AttributeOption::findOrFail($value);
$qtyHtml .= '<div id="qty_option_id">';
$qtyHtml .= '<div class="row '.$config_opt->attribute->name.'" style="display: none;">'. $config_opt->option.'<input type="text" name="option_qty[]" class="form-control" >';
$qtyHtml .= '</div>';
$qtyHtml .= '</div>';
}
$qtyHtml .= '</div>';
return response()->json(['success'=>'Successfully',
'imageHtml' => $imageHtml,
'priceHtml' => $priceHtml,
'qtyHtml' => $qtyHtml,
'count' => $count,
]);
}
Here When user select the attribute option , option are stored and used in next step where user can store the option value with respect to attribute
Step 3: Bulk Images, Price and Quantity
After selecting "Apply unique price by attribute to each sku"
View file
<p class="small hint-text m-b-10 m-t-20">
Price
</p>
<div class="form-check">
<input type="radio" name="price" id="price1">
<label for="price1">
Apply single of price to all SKUs
</label>
</div>
<div class="form-check">
<input type="radio" name="price" id="price2">
<label for="price2">
Apply unique prices by attribute to each SKU
</label>
</div>
<div class="form-check">
<input type="radio" name="price" id="price3" checked="checked">
<label for="price3">
Skip price at this time
</label>
</div>
<div class="form-group col-lg-4">
<input type="text" class="form-control" name="single_config_price" id="single_config_price" style="display: none" placeholder="Please enter Price">
</div>
<div id="stepTwoPriceResponse">
</div>
<button class="btn btn-cons btn-primary" id="stepThree">Next</button>
Here I have shown only for price response. Please consider it that Image and Quantity section too
Here I have tried to append all the attribute select option .. and when user select the attribute another input section appear respectively where the user can enter the attribute option value
When user hit next
Ajax is call having code
$('#stepThree').click(function(e){
e.preventDefault();
var option = "";
$("input[name='option_price[]']").each(function () {
if($(this).val()) {
option += $(this).val() + ",";
}
});
console.log(option);
$.ajax({
url: "/configStepThree",
type:"POST",
data:{
"_token": "{{ csrf_token() }}",
option:option,
},
success:function(response){
$('#successMsg').show();
console.log(response);
$("#tabImageNav").removeClass("active");
$("#tabImage").removeClass("active");
$('#tabDetailNav').addClass('active');
$('#tabDetail').addClass('active');
$('#table').append(response.table);
},
error: function(response) {
// $('#nameErrorMsg').text(response.responseJSON.errors.message);
console.log(response.responseJSON.message);
},
});
});
});
In configStepThree method from controller
public function configStepThree(Request $request) {
if (!is_null(Session::get('mulit_options'))) {
// Session::forget('mulit_options');
}
Session::put('mulit_options', $request->option);
$config_attribute = "";
$config_attribute_opt_string = "";
$config_attribute_array = [];
$config_attribute_opt_array = [];
$config_attribute_opt_array_id = [];
if (!is_null(Session::get('attributes'))) {
$config_attribute = Session::get('attributes');
$config_attribute = substr($config_attribute, 0, -1);
$config_attribute_array = explode(',', $config_attribute);
}
if (!is_null(Session::get('options'))) {
$config_attribute_opt = Session::get('options');
$config_attribute_opt = substr($config_attribute_opt, 0, -1);
$config_attribute_opt_array = explode(',', $config_attribute_opt);
}
if (!is_null(Session::get('options_id'))) {
$config_attribute_opt_id = Session::get('options_id');
$config_attribute_opt_id = substr($config_attribute_opt_id, 0, -1);
$config_attribute_opt_array_id = explode(',', $config_attribute_opt_id);
}
foreach ($config_attribute_opt_array_id as $key => $value) {
$config_attribute_opt_string .= strstr($value, '-', true). ',';
}
$count = Session::get('count');
$table = "";
$table .= '<table class="table table-hover " >';
$table .= '<thead>';
$table .= '<tr>';
$table .= '<th style="width:30%">Image</th>';
$table .= '<th style="width:30%">SKU</th>';
$table .= '<th style="width:40%">Quantity</th>';
foreach ($config_attribute_array as $key => $attribute) {
$config_attr = Attributee::findOrFail($attribute);
$table .= '<th style="width:40%">'.$config_attr->name.'</th>';
}
$table .= '<th style="width:40%">Price</th>';
$table .= '</tr>';
$table .= '</thead>';
$table .= '<tbody>';
//This is what I want as collection
$collection = [
[
'Color' => 'Red',
'Size' => 'XL',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Red',
'Size' => 'SM',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'XL',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'SM',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
]
];
// dd($collection);
// for ($i=1; $i <= $count; $i++) {
foreach ($collection as $key => $value) {
$table .= '<tr>';
$table .= '<td class="v-align-middle semi-bold"><img src="../assets/img/thumbnail.jpg" class="img-thumbnail"><span class="badge bage-alert bagde-top">'.$value['image_count'].'</span></td>';
$table .= '<td class="v-align-middle">Simple but not simpler</td>';
$table .= '<td class="v-align-middle semi-bold">'.$value['qty'].'</td>';
foreach ($config_attribute_array as $key => $attribute) {
$config_attr = Attributee::findOrFail($attribute);
$table .= '<td class="v-align-middle semi-bold">'.$value[''.$config_attr->name.''].'</td>';
}
$table .= '<td class="v-align-middle semi-bold">'.$value['price'].'</td>';
$table .='</tr>';
}
// }
$table .= '</tbody>';
$table .= '</table>';
return response()->json(['success'=>'Successfully',
'table' => $table,
]);
}
Step : 4 Summary Table
view blade file code
Here I want to display all the values respective from previous steps.
Note
$collection = [
[
'Color' => 'Red',
'Size' => 'XL',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Red',
'Size' => 'SM',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'XL',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'SM',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
]
];
is static collection that I have manually created. I want this collection to be created dynamically iterating the values from previous step. Please let me know how can I achieve this.
Please do not judge me on my code. I am bit new to this and my code is not clean and I have repeated the code not following DRY principle.

Convert Magento Configurable product to Custom Laravel Configurable product using Ajax

Currently I am trying to convert Magento Configurable product to Custom Laravel configurable product.
In step one I am displaying all the attributes from backend
Step 1: Select Attributes
(Here I have displayed all the attributes from backend)
my view blade code
<div class="container">
<div class="row p-b-35">
<div class="form-group">
#foreach($attributes as $attribute)
<div class="form-check complete">
<input type="checkbox" id="{{$attribute->id}}" name="attribute[]" value="{{$attribute->id}}">
<label for="{{$attribute->id}}">
{{$attribute->name}}
</label>
</div>
#endforeach
</div>
</div>
<button class="btn btn-cons btn-primary" id="stepOne">Next</button>
</div>
once the user check the attribute I have use ajax to store the attribute id
ajax code
$('#stepOne').click(function(e){
e.preventDefault();
var attribute = "";
$(":checkbox").each(function () {
var ischecked = $(this).is(":checked");
if (ischecked) {
attribute += $(this).val() + ",";
}
});
$.ajax({
url: "/configStepOne",
type:"POST",
data:{
"_token": "{{ csrf_token() }}",
attribute:attribute,
},
success:function(response){
$('#successMsg').show();
$('#stepOneResponse').append(response.html);
},
error: function(response) {
console.log(response.responseJSON.message);
},
});
});
In mine controller method (configStepOne)
public function configStepOne(Request $request) {
if (!is_null(Session::get('attributes'))) {
Session::forget('attributes');
}
Session::put('attributes', $request->attribute);
$config_attribute_array = [];
if (!is_null(Session::get('attributes'))) {
$config_attribute = Session::get('attributes');
$config_attribute = substr($config_attribute, 0, -1);
$config_attribute_array = explode(',', $config_attribute);
}
$html = "";
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$html .= '<p class="small hint-text m-b-20">'.$config_attr->name.'</p>';
foreach($config_attr->options as $option) {
$html .= '<div class="form-check complete">';
$html .= '<input type="checkbox" id="'.$config_attr->name. '-' .$option->id.'-'.$option->option.'" name="option[]" value="'.$option->id.'">';
$html .= '<label for="'.$config_attr->name.'-'.$option->id.'-'.$option->option.'">'.$option->option.'</label>';
$html .= '</div>';
}
$html .= '<br>';
}
return response()->json(['success'=>'Successfully', 'html' => $html]);
}
Here I am trying to get the attributes respective options from backend and append the response to blade view
Step 2: Attribute Values
In mine blade view I have
<div id="stepOneResponse">
</div>
<button class="btn btn-cons btn-primary" id="stepTwo">Next</button>
From ajax append the blade view is updated as
<div id="stepOneResponse">
<p class="small hint-text m-b-20">Color</p>
<div class="form-check complete"><input type="checkbox" id="Color-1-Red" name="option[]" value="1"><label for="Color-1-Red">Red</label></div>
<div class="form-check complete"><input type="checkbox" id="Color-2-Black" name="option[]" value="2"><label for="Color-2-Black">Black</label></div>
<div class="form-check complete"><input type="checkbox" id="Color-7-Blue" name="option[]" value="7"><label for="Color-7-Blue">Blue</label></div>
<div class="form-check complete"><input type="checkbox" id="Color-8-Green" name="option[]" value="8"><label for="Color-8-Green">Green</label></div>
<br>
<p class="small hint-text m-b-20">Size</p>
<div class="form-check complete"><input type="checkbox" id="Size-3-XL" name="option[]" value="3"><label for="Size-3-XL">XL</label></div>
<div class="form-check complete"><input type="checkbox" id="Size-4-SM" name="option[]" value="4"><label for="Size-4-SM">SM</label></div>
<div class="form-check complete"><input type="checkbox" id="Size-9-medium" name="option[]" value="9"><label for="Size-9-medium">medium</label></div>
<div class="form-check complete"><input type="checkbox" id="Size-10-Extra small" name="option[]" value="10"><label for="Size-10-Extra small">Extra small</label></div>
<br>
<p class="small hint-text m-b-20">Format</p>
<div class="form-check complete"><input type="checkbox" id="Format-13-Download" name="option[]" value="13"><label for="Format-13-Download">Download</label></div>
<div class="form-check complete"><input type="checkbox" id="Format-14-DVD" name="option[]" value="14"><label for="Format-14-DVD">DVD</label></div>
<br>
</div>
<button class="btn btn-cons btn-primary" id="stepTwo">Next</button>
ajax code :
$('#stepTwo').click(function(e){
e.preventDefault();
var option = "";
var option_id = "";
$("#stepOneResponse :checkbox").each(function () {
var ischecked = $(this).is(":checked");
if (ischecked) {
option += $(this).val() + ",";
option_id += $(this).attr('id') + ",";
}
});
$.ajax({
url: "/configStepTwo",
type:"POST",
data:{
"_token": "{{ csrf_token() }}",
option:option,
option_id:option_id,
},
success:function(response){
$('#successMsg').show();
console.log(response);
$('#stepTwoImageResponse').append(response.imageHtml);
$('#stepTwoPriceResponse').append(response.priceHtml);
$('#stepTwoQtyResponse').append(response.qtyHtml);
$('#count').text(response.count);
},
error: function(response) {
console.log(response.responseJSON.message);
},
});
});
In Controller method configStepTwo
public function configStepTwo(Request $request) {
if (!is_null(Session::get('options'))) {
// Session::forget('option');
}
Session::put('options', $request->option);
Session::put('options_id', $request->option_id);
$config_attribute = "";
$config_attribute_opt_string = "";
$config_attribute_array = [];
$config_attribute_opt_array = [];
$config_attribute_opt_array_id = [];
if (!is_null(Session::get('attributes'))) {
$config_attribute = Session::get('attributes');
$config_attribute = substr($config_attribute, 0, -1);
$config_attribute_array = explode(',', $config_attribute);
// dd($config_attribute_array);
}
if (!is_null(Session::get('options'))) {
$config_attribute_opt = Session::get('options');
$config_attribute_opt = substr($config_attribute_opt, 0, -1);
$config_attribute_opt_array = explode(',', $config_attribute_opt);
// dd($config_attribute_opt_array);
}
if (!is_null(Session::get('options_id'))) {
$config_attribute_opt_id = Session::get('options_id');
// $config_attribute_opt_id = strstr($config_attribute_opt_id, '-', true);
$config_attribute_opt_id = substr($config_attribute_opt_id, 0, -1);
$config_attribute_opt_array_id = explode(',', $config_attribute_opt_id);
}
foreach ($config_attribute_opt_array_id as $key => $value) {
$config_attribute_opt_string .= strstr($value, '-', true). ',';
// $config_attribute_opt_string .= $value. ',';
}
$config_attribute_opt_string = substr($config_attribute_opt_string, 0, -1);
$config_attribute_opt_array_id = explode(',', $config_attribute_opt_string);
$array_count = array_count_values($config_attribute_opt_array_id);
$count = 1;
foreach ($array_count as $key => $value) {
$count *= $value;
}
Session::put('count', $count);
$imageHtml = "";
$imageHtml .= '<div class="form-group col-lg-4" id="multi_config_image" style="display: none">
<label for="type">Select attribute </label>
<select name="image_attribute_id" class="form-control" id="image_attribute_id">
<option value="">Select</option>';
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$imageHtml .= '<option value="'.$config_attr->name.'">'.$config_attr->name.'</option>';
}
$imageHtml .= '</select>';
foreach($config_attribute_opt_array as $value) {
$config_opt = AttributeOption::findOrFail($value);
$imageHtml .= '<div id="image_option_id">';
$imageHtml .= '<div class="row '.$config_opt->attribute->name.'" style="display: none;">'. $config_opt->option.'<input type="file" name="option_image" class="form-control" >';
$imageHtml .= '</div>';
$imageHtml .= '</div>';
}
$imageHtml .= '</div>';
$priceHtml = "";
$priceHtml .= '<div class="form-group col-lg-4" id="multi_config_price" style="display: none">
<label for="type">Select attribute </label>
<select name="price_attribute_id" class="form-control" id="price_attribute_id">
<option value="">Select</option>';
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$priceHtml .= '<option value="'.$config_attr->name.'">'.$config_attr->name.'</option>';
}
$priceHtml .= '</select>';
foreach($config_attribute_opt_array as $value) {
$config_opt = AttributeOption::findOrFail($value);
$priceHtml .= '<div id="price_option_id">';
$priceHtml .= '<div class="row '.$config_opt->attribute->name.'" style="display: none;">'. $config_opt->option.'<input type="text" name="option_price[]" class="form-control" >';
$priceHtml .= '</div>';
$priceHtml .= '</div>';
}
$priceHtml .= '</div>';
$qtyHtml = "";
$qtyHtml .= '<div class="form-group col-lg-4" id="multi_config_qty" style="display: none">
<label for="type">Select attribute </label>
<select name="qty_attribute_id" class="form-control" id="qty_attribute_id">
<option value="">Select</option>';
foreach($config_attribute_array as $value) {
$config_attr = Attributee::findOrFail($value);
$qtyHtml .= '<option value="'.$config_attr->name.'">'.$config_attr->name.'</option>';
}
$qtyHtml .= '</select>';
foreach($config_attribute_opt_array as $value) {
$config_opt = AttributeOption::findOrFail($value);
$qtyHtml .= '<div id="qty_option_id">';
$qtyHtml .= '<div class="row '.$config_opt->attribute->name.'" style="display: none;">'. $config_opt->option.'<input type="text" name="option_qty[]" class="form-control" >';
$qtyHtml .= '</div>';
$qtyHtml .= '</div>';
}
$qtyHtml .= '</div>';
return response()->json(['success'=>'Successfully',
'imageHtml' => $imageHtml,
'priceHtml' => $priceHtml,
'qtyHtml' => $qtyHtml,
'count' => $count,
]);
}
Here When user select the attribute option , option are stored and used in next step where user can store the option value with respect to attribute
Step 3: Bulk Images, Price and Quantity
After selecting "Apply unique price by attribute to each sku"
View file
<p class="small hint-text m-b-10 m-t-20">
Price
</p>
<div class="form-check">
<input type="radio" name="price" id="price1">
<label for="price1">
Apply single of price to all SKUs
</label>
</div>
<div class="form-check">
<input type="radio" name="price" id="price2">
<label for="price2">
Apply unique prices by attribute to each SKU
</label>
</div>
<div class="form-check">
<input type="radio" name="price" id="price3" checked="checked">
<label for="price3">
Skip price at this time
</label>
</div>
<div class="form-group col-lg-4">
<input type="text" class="form-control" name="single_config_price" id="single_config_price" style="display: none" placeholder="Please enter Price">
</div>
<div id="stepTwoPriceResponse">
</div>
<button class="btn btn-cons btn-primary" id="stepThree">Next</button>
Here I have shown only for price response. Please consider it that Image and Quantity section too
Here I have tried to append all the attribute select option .. and when user select the attribute another input section appear respectively where the user can enter the attribute option value
When user hit next
Ajax is call having code
$('#stepThree').click(function(e){
e.preventDefault();
var option = "";
$("input[name='option_price[]']").each(function () {
if($(this).val()) {
option += $(this).val() + ",";
}
});
console.log(option);
$.ajax({
url: "/configStepThree",
type:"POST",
data:{
"_token": "{{ csrf_token() }}",
option:option,
},
success:function(response){
$('#successMsg').show();
console.log(response);
$("#tabImageNav").removeClass("active");
$("#tabImage").removeClass("active");
$('#tabDetailNav').addClass('active');
$('#tabDetail').addClass('active');
$('#table').append(response.table);
},
error: function(response) {
// $('#nameErrorMsg').text(response.responseJSON.errors.message);
console.log(response.responseJSON.message);
},
});
});
});
In configStepThree method from controller
public function configStepThree(Request $request) {
if (!is_null(Session::get('mulit_options'))) {
// Session::forget('mulit_options');
}
Session::put('mulit_options', $request->option);
$config_attribute = "";
$config_attribute_opt_string = "";
$config_attribute_array = [];
$config_attribute_opt_array = [];
$config_attribute_opt_array_id = [];
if (!is_null(Session::get('attributes'))) {
$config_attribute = Session::get('attributes');
$config_attribute = substr($config_attribute, 0, -1);
$config_attribute_array = explode(',', $config_attribute);
}
if (!is_null(Session::get('options'))) {
$config_attribute_opt = Session::get('options');
$config_attribute_opt = substr($config_attribute_opt, 0, -1);
$config_attribute_opt_array = explode(',', $config_attribute_opt);
}
if (!is_null(Session::get('options_id'))) {
$config_attribute_opt_id = Session::get('options_id');
$config_attribute_opt_id = substr($config_attribute_opt_id, 0, -1);
$config_attribute_opt_array_id = explode(',', $config_attribute_opt_id);
}
foreach ($config_attribute_opt_array_id as $key => $value) {
$config_attribute_opt_string .= strstr($value, '-', true). ',';
}
$count = Session::get('count');
$table = "";
$table .= '<table class="table table-hover " >';
$table .= '<thead>';
$table .= '<tr>';
$table .= '<th style="width:30%">Image</th>';
$table .= '<th style="width:30%">SKU</th>';
$table .= '<th style="width:40%">Quantity</th>';
foreach ($config_attribute_array as $key => $attribute) {
$config_attr = Attributee::findOrFail($attribute);
$table .= '<th style="width:40%">'.$config_attr->name.'</th>';
}
$table .= '<th style="width:40%">Price</th>';
$table .= '</tr>';
$table .= '</thead>';
$table .= '<tbody>';
//This is what I want as collection
$collection = [
[
'Color' => 'Red',
'Size' => 'XL',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Red',
'Size' => 'SM',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'XL',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'SM',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
]
];
// dd($collection);
// for ($i=1; $i <= $count; $i++) {
foreach ($collection as $key => $value) {
$table .= '<tr>';
$table .= '<td class="v-align-middle semi-bold"><img src="../assets/img/thumbnail.jpg" class="img-thumbnail"><span class="badge bage-alert bagde-top">'.$value['image_count'].'</span></td>';
$table .= '<td class="v-align-middle">Simple but not simpler</td>';
$table .= '<td class="v-align-middle semi-bold">'.$value['qty'].'</td>';
foreach ($config_attribute_array as $key => $attribute) {
$config_attr = Attributee::findOrFail($attribute);
$table .= '<td class="v-align-middle semi-bold">'.$value[''.$config_attr->name.''].'</td>';
}
$table .= '<td class="v-align-middle semi-bold">'.$value['price'].'</td>';
$table .='</tr>';
}
// }
$table .= '</tbody>';
$table .= '</table>';
return response()->json(['success'=>'Successfully',
'table' => $table,
]);
}
Step : 4 Summary Table
view blade file code
Here I want to display all the values respective from previous steps.
Note
$collection = [
[
'Color' => 'Red',
'Size' => 'XL',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Red',
'Size' => 'SM',
'Format' => 'Download',
'price' => '200',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'XL',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
],
[
'Color' => 'Black',
'Size' => 'SM',
'Format' => 'Download',
'price' => '300',
'qty' => '1',
'image' => 'path',
'image_count' => '0'
]
];
is static collection that I have manually created. I want this collection to be created dynamically iterating the values from previous step. Please let me know how can I achieve this.
Please do not judge me on my code. I am bit new to this and my code is not clean and I have repeated the code not following DRY principle.
For image reference please checkout this link magento configuration product to custom laravel configurable product using ajax

datewise searching not working in pagination

My search result correctly displaying. But when I click the second page or pagination then all the data is displaying
my view - date selecting
Here I select the date using the date picker
<div class='floatl modal-form col-sm-12'>
<div class='col-sm-5'>
<input type='text' class='dateTablePicker' readonly id='dateTableFrom'
placeholder='date from'/>
</div>
<div class='col-sm-5'>
<input type='text' class='dateTablePicker' readonly id='dateTableTo'
placeholder='date to'/>
</div>
<div class='col-sm-2'>
<button class='btn-success' onclick="filterTable()"> Filter</button>
</div>
</div>
<div class='contentTable'>
<?php
$this->load->view("pages/tableData/leads_data");
?>
</div>
<script>
$(function () {
$(".dateTablePicker").datepicker({dateFormat: 'yy-mm-dd'});
});
function filterTable() {
$.ajax({
type: "POST",
url: "<?= site_url('OperationRouter/filterTableData'); ?>",
data: {dateTableFrom: $('#dateTableFrom').val(), dateTableTo: $('#dateTableTo').val()},
success: function (data) {
$(".contentTable").html(data);
}
});
}
leads_data//table data listing
The data displaying if the datefrom and dateto is isset then data displaying based on searching.
<?php
if (!isset($_SESSION['dateTableFrom'])) $_SESSION['dateTableFrom'] = '';
if (!isset($_SESSION['dateTableTo'])) $_SESSION['dateTableTo'] = '';
$dateTableFrom = $_SESSION['dateTableFrom'];
$dateTableTo = $_SESSION['dateTableTo'];
$page='leads';
$slno = 0;
// CONDITION QUERY
if (isset($_SESSION['export_Sql']))
$cql = $_SESSION['export_Sql'];
else if($dateTableFrom) {
$cql = '
select leads.id,leads.created,leads.product_id,
leads.company_id,leads.owner_id,leads.creator_id,
leads.title,leads.date,products.title as product,
leads.converted_flag,leads.status,
companies.title as company,admin.username
from admin admin,products products,leads leads,companies
companies
where products.id=leads.product_id
and companies.id=leads.company_id
and admin.id=leads.owner_id
and leads.remove_status = 1
and
( leads.creator_id = ' . $this->session-
>userdata['logged_admin'] . '
or FIND_IN_SET(leads.creator_id, ( select
GROUP_CONCAT(id) from admin
where parent_id =' . $this->session-
>userdata['logged_admin'] . ' ))
)
and STR_TO_DATE(leads.created,"%d-%m-%Y") >= "' . $dateTableFrom . '"
and
STR_TO_DATE(leads.created,"%d-%m-%Y") <= "' . $dateTableTo . '"
';
}
else
{
$cql = '
select leads.id,leads.created,leads.product_id,
leads.company_id,leads.owner_id,leads.creator_id,
leads.title,leads.date,products.title as product,
leads.converted_flag,leads.status,
companies.title as company,admin.username
from admin admin,products products,leads leads,companies
companies
where products.id=leads.product_id
and companies.id=leads.company_id
and admin.id=leads.owner_id
and leads.remove_status = 1
and
( leads.creator_id = ' . $this->session-
>userdata['logged_admin'] . '
or FIND_IN_SET(leads.creator_id, ( select
GROUP_CONCAT(id) from admin
where parent_id =' . $this->session-
>userdata['logged_admin'] . ' ))
)
';
}
if (isset($_SESSION['export_Ids']) && $_SESSION['export_Ids']) {
$cql .= " and leads.id in (" . $_SESSION['export_Ids'] . ") ";
}
if (isset($_SESSION['export_Order']) &&
$_SESSION['export_Order'])
$oql = $_SESSION['export_Order'];
else
$oql = ''; // ORDER QUERY
if (isset($_SESSION['export_Limit']))
$lql = $_SESSION['export_Limit'];
else
$lql='';
if (isset($_SESSION['export_Ids']) && $_SESSION['export_Ids']) // IF ID'S
THEN NO EXPORT LIMIT NEEDED
$lql = '';
$sql = $cql . $oql;
$itemcount = $this->OperationModel->getRowCount($sql);
$sql = $cql . $oql . $lql;
?>
<input type='hidden' id='selectedSql' value='<?= $cql ?>'/>
<input type='hidden' id='selectedOrder' value='<?= $oql ?>'/>
<input type='hidden' id='selectedLimit' value='<?= $lql ?>'/>
<?php
$slno = 0;
//$sql='select * from admin_types where remove_status = 1';
$tableArray['searchFields'] = 'leads.title';
$itemsperpage = 6;
$result = $this->OperationModel->getTableData($sql,
$tableArray['searchFields'], $itemsperpage);
if (isset($result['data'])) {
$admin_det = $this->Adminuser->getsingleadmin($this->session-
>userdata['logged_admin']);
?>
<div class='custom-data-table '>
<table class='customtable'>
<tr>
<th style='width:70px;' class='checker'>
<input type='checkbox' class='thCheckbox'/>
<div class='customCheckbox'></div>
</th>
<th style='width:60px;'> No</th>
<th style='width:230px;'>
Title
<div class='floatr'><i class='i-sorter icon-shuffle'
data='leads.title'
title='sort records by title'></i>
</div>
</th>
<th>
Date
<div class='floatr'><i class='i-sorter icon-shuffle'
data='leads.created'
title='sort records by date '></i>
</div>
</th>
<th>
Service
<div class='floatr'><i class='i-sorter icon-shuffle'
data='products.title'
title='sort records by date '></i>
</div>
</th>
<th>
Client
<div class='floatr'><i class='i-sorter icon-shuffle'
data='companies.title'
title='sort records by company'>
</i></div>
</th>
<th>
Owner
<div class='floatr'><i class='i-sorter icon-shuffle'
data='admin.username'
title='sort records by owner'></i></div>
</th>
<?php if ($page != 'excelexport') { ?>
<?php if ($admin_det[0]['user_type'] == 'admin' ||
$admin_det[0]['user_type'] == 2) { ?>
<th> Conversion
<div class='floatr'><i class='i-sorter icon-
shuffle' data='leads.converted_flag'
title='sort records by
conversion status'></i></div>
</th>
<?php } ?>
<!--
<th>
Status
</th>
!-->
<th> Actions</th>
<?php } ?>
</tr>
<?php
// $slno=intval($current_page);
if (isset($searchkey)) $searchkey = $searchkey; else $searchkey
= '**';
foreach ($result['data'] as $row) {
$slno++;
?>
<tr id='<?= $row['id'] ?>'>
<td>
<input type='checkbox' class='tdCheckbox'/>
<div id='<?= $row['id'] ?>' class='customCheckbox'>
</div>
</td>
<td> <?= $slno ?> </td>
<td><?= $this->OperationModel-
>searchKeyCheck($row['title'], $searchkey) ?></td>
<td><?= $row['created'] ?></td>
<td><?= $this->OperationModel-
>searchKeyCheck($row['product'], $searchkey) ?></td>
<td><?= $this->OperationModel-
>searchKeyCheck($row['company'], $searchkey) ?></td>
<td><?= $this->OperationModel-
>searchKeyCheck($row['username'], $searchkey) ?></td>
<!--
<td><?= $row['lead_status'] ? '<span
style="color:green">Active</span>' : '<span
style="color:orange">Inactive</span>' ?></td>
!-->
<?php if ($page != 'excelexport') { ?>
<?php if ($admin_det[0]['user_type'] == 'admin' ||
$admin_det[0]['user_type'] == 2) { ?>
<td>
<button class='status-button'
data-trigger='leads'
data-value='<?=
$row['converted_flag'] ?>'
data-raw='<?= $row['id'] ?>'
data-field='converted_flag'
data-success="<span
class='colorange'>DisConvert</span>"
data-failure="<span
class='colgreen'>Convert</span>">
<?= ($row['converted_flag'] == 1) ? "
<span class='colorange'>DisConvert</span>" : "<span
class='colgreen'>Convert</span>" ?>
</button>
</td>
<?php } ?>
<td>
<?php
if ($row['creator_id'] ==
$_SESSION['logged_admin'] || $admin_det[0]['user_type'] ==
'admin' || $admin_det[0]['user_type'] == 2) { ?>
<a class='modal-switch'
data-toggle='modal'
data-target='#getAppUsers'
data-ajax='createmeeting'>
<i class='fa fa-plus add-bt'></i>
Meeting
</a>
<a class='modal-switch'
data-toggle='modal'
data-target='#getAppUsers'
data-ajax='createlead' data-raw='<?=
$row['id'] ?>'>
<i class='fa fa-pencil ed-bt'></i>
</a>
<?php if ($admin_det[0]['user_type'] ==
'admin') { ?>
<a class='delete-trigger' data-
trigger='leads' data-raw='<?= $row['id'] ?>'>
<i class='fa fa-trash del-bt'></i>
</a>
<?php } ?>
<?php } ?>
<a class='modal-switch'
data-toggle='modal'
data-operation='view'
data-target='#getAppUsers'
data-ajax='createlead' data-raw='<?=
$row['id'] ?>'>
<i class='fa fa-eye ed-bt'></i>
</a>
</td>
<?php } ?>
</tr>
<?php
}
?>
</table>
</div>
<?php
/* THE PAGINATION PART */
$pagination['base_url'] = $page;
$pagination['itemsperpage'] = $itemsperpage;
$pagination['total_rows'] = $this->OperationModel->getRowCount($sql,
$tableArray['searchFields']);
/* THE PAGINATION PART */
if (isset($pagination))
echo $this->OperationModel->getPagination($pagination);
?>
<?php
} else {
echo " <span class='floatl no-match-span'> <i class='icon-magnifier'></i>
<span>Oopz , No data found in database for the corresponding item .
</span> </span> ";
}
?>
<?php
$this->session->unset_userdata('dateTableFrom');
?>
pagination part
Here is the pagination part
function getPagination($dataArray = '')
{
$msg = '';
if ($dataArray) {
$this->load->library('pagination');
$config['base_url'] = base_url() . $dataArray['base_url'];
//$config['base_url'] = base_url('controller_name/search');
$config['uri_segment'] = 2;
$config['total_rows'] = $dataArray['total_rows'];
$config['per_page'] = $dataArray['itemsperpage'];
$this->pagination->initialize($config);
$msg .= "<div class='pagination'>";
$msg .= $this->pagination->create_links();
$msg .= "</div>";
return $msg;
} else
return false;
}
You should pass the search params (filters) along with the ajax request. (along with the pagination)

One View for Edit and Add in controller function itself using CodeIgniter

I am using in the Below code for edit data as shown below but not working for me.
$tbody .= '<input placeholder="Start Date" id="ed" type="text" class="form-control hasDatepicker" name="start_date" value="'if($config->metrcsettingconf_master_id == $store_products->master_id){ echo $config->metrcsettingconf_startdate} else{ echo ""}'">';
In the code value="" in the input field of form. Add is working fine but after adding data, i want to edit form same company and store selection.
function get_master() {
$store_id = $this->input->post('store_id');
$get_store = $this->common->get_row(array(
'store_id' => $store_id
), DBPREFIX . "store");
$store = $get_store->store_state_id;
$company = $get_store->store_company_id;
$this->session->set_userdata('store', $store);
$this->session->set_userdata('company', $company);
$data['master'] = $master = $this->common->get_whereresult(DBPREFIX . 'apimaster', array('master_status' => 1, 'master_state' => $store), 'master_name');
$tbody = '';
foreach ($master as $store_products) {
$config = $this->common->get_whereresult(DBPREFIX . 'metrcsetting_conf', array('metrcsettingconf_status' => 1, 'metrcsettingconf_master_id' => $store_products->master_id, 'metrcsettingconf_company_id' => $company, 'metrcsettingconf_store_id' => $store_id));
$tbody .= '<div class="row">';
$tbody .= '<div class="form-group col-md-12 col-sm-12 col-xs-12">';
$tbody .= '<div class="panel panel-default">';
$tbody .= '<div class="panel-heading" role="tab" id="headingOne">';
$tbody .= '<h4 class="panel-title" style="height:18px;">';
$tbody .= '<form action="add_metrcsettingmaster/' . $store_products->master_id . '" method="post">';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12">';
$tbody .= '<a data-toggle="collapse" data-parent="#accordion" id="master_id" href="#collapseOne'. $store_products->master_id .'" aria-expanded="true" aria-controls="collapseOne'. $store_products->master_id .'">' . $store_products->master_name . '</a>';
$tbody .= '<input id="master_idd" type="hidden" value="' . $store_products->master_id . '">';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12 start_date" style="margin-top:-8px;">';
$tbody .= '<input placeholder="Start Date" id="ed" type="text" class="form-control hasDatepicker" name="start_date" value="">';
$tbody .= '<span class="start_datetext">Sync Active</span>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12 end_date" style="margin-top:-8px;">';
$tbody .= '<input placeholder="End Date" id="jd" type="text" class="form-control hasDatepicker" name="end_date" value="">';
$tbody .= '<span class="end_datetext">Sync Expire</span>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-lg-2 col-sm-2 col-xs-12 time" style="margin-top:-5px;">';
$tbody .= '<input type="time" name="time" class="form-control" value="">';
$tbody .= '<span class="timetext">Sync Time</span>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12" style="margin-top: -5px">';
$tbody .= '<select name="days[]" class="form-control status chosen-select" multiple="multiple">';
$tbody .= '<option value="Monday">Monday</option>';
$tbody .= '<option value="Tuesday">Tuesday</option>';
$tbody .= '<option value="Wednesday">Wednesday</option>';
$tbody .= '<option value="Thursday">Thursday</option>';
$tbody .= '<option value="Friday">Friday</option>';
$tbody .= '<option value="Saturday">Saturday</option>';
$tbody .= '<option value="Sunday">Sunday</option>';
$tbody .= '</select>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-lg-2 col-sm-2 col-xs-12" style="margin-top:-8px;text-align:center;">';
$tbody .= '<label class="switch">';
$tbody .= '<p style="margin-top:10px;margin-left:-60px;"> Manual </p>';
$tbody .= '<p style="margin-top:-27px;margin-left:60px;"> Auto </p>';
$tbody .= '<input type="checkbox" name="manauto" id="chkPassportt" value="">';
$tbody .= '<span class="slider round"></span>';
//$tbody .= 'form_error('"manauto"');';
$tbody .= '</label>';
$tbody .= '</div>';
$tbody .= '<div class="col-md-2 col-lg-2 col-sm-2 col-xs-12 pull-right" style="margin-top:-8px;">';
$tbody .= '<input class="btn btn-danger" type="submit" name="submit" value="Submit">';
$tbody .= '</div>';
$tbody .= '</form>';
$tbody .= '</h4>';
$tbody .= '</div>';
$tbody .= '<div id="collapseOne'. $store_products->master_id .'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">';
$tbody .= '<div class="panel-body">';
$tbody .= '<div id="childdata">';
$master_id = $store_products->master_id;
$data['child'] = $child = $this->common->get_whereresult(DBPREFIX . 'apichild', array('child_status' => 1, 'child_master' => $master_id), 'child_apiname');
foreach ($child as $store_products) {
$tbody .= '<div class="row">';
$tbody .= '<div class="form-group col-md-12 col-sm-12 col-xs-12">';
$tbody .= '<div class="panel panel-default">';
$tbody .= '<div class="panel-heading" role="tab" id="headingOne">';
$tbody .= '<h4 class="panel-title" style="height:18px;">';
$tbody .= '<form action="add_metrcsettingchild/' . $store_products->child_id . '" method="post">';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12">';
$tbody .= '<a data-toggle="collapse" data-parent="#accordion" id="child_id" href="#collapseOne'. $store_products->child_id .'" aria-expanded="true" aria-controls="collapseOne'. $store_products->child_id .'">' . $store_products->child_apiname . '</a>';
$tbody .= '<input id="child_idd" type="hidden" value="' . $store_products->child_id . '">';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12 start_date" style="margin-top:-8px;">';
$tbody .= '<input placeholder="Start Date" id="ed" type="text" class="form-control hasDatepicker" name="start_date" value="">';
$tbody .= '<span class="start_datetext">Sync Active</span>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12 end_date" style="margin-top:-8px;">';
$tbody .= '<input placeholder="End Date" id="jd" type="text" class="form-control hasDatepicker" name="end_date" value="">';
$tbody .= '<span class="end_datetext">Sync Expire</span>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-lg-2 col-sm-2 col-xs-12 time" style="margin-top:-5px;">';
$tbody .= '<input type="time" name="time">';
$tbody .= '<span class="timetext">Sync Time</span>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-sm-2 col-xs-12" style="margin-top: -5px">';
$tbody .= '<select name="days[]" class="form-control status chosen-select" multiple="multiple">';
$tbody .= '<option value="Monday">Monday</option>';
$tbody .= '<option value="Tuesday">Tuesday</option>';
$tbody .= '<option value="Wednesday">Wednesday</option>';
$tbody .= '<option value="Thursday">Thursday</option>';
$tbody .= '<option value="Friday">Friday</option>';
$tbody .= '<option value="Saturday">Saturday</option>';
$tbody .= '<option value="Sunday">Sunday</option>';
$tbody .= '</select>';
$tbody .= '</div>';
$tbody .= '<div class="form-group col-md-2 col-lg-2 col-sm-2 col-xs-12" style="margin-top:-8px;text-align:center;">';
$tbody .= '<label class="switch">';
$tbody .= '<p style="margin-top:10px;margin-left:-60px;"> Manual </p>';
$tbody .= '<p style="margin-top:-27px;margin-left:60px;"> Auto </p>';
$tbody .= '<input type="checkbox" name="manauto" id="chkPassportt">';
$tbody .= '<span class="slider round"></span>';
//$tbody .= 'form_error('"manauto"');';
$tbody .= '</label>';
$tbody .= '</div>';
$tbody .= '<div class="col-md-2 col-lg-2 col-sm-2 col-xs-12 pull-right" style="margin-top:-8px;">';
$tbody .= '<input class="btn btn-danger" type="submit" name="submit" value="Submit">';
$tbody .= '</div>';
$tbody .= '</form>';
$tbody .= '</h4>';
$tbody .= '</div>';
$tbody .= '<div id="collapseOne'. $store_products->child_id .'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">';
$tbody .= '<div class="panel-body">';
$tbody .= '<div id="childdata"></div>';
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
}
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
$tbody .= '</div>';
}
echo $tbody;
}
In the code value="" in the input field of form. Add is working fine but after adding data, i want to edit form.

Error: Syntax error, unrecognized expression: javascript:TagPopup_OpenForm(

I am getting this error.It is running perfectly on localhost.
Error: Syntax error, unrecognized expression: javascript:TagPopup_OpenForm("TagPopup_FormContainer1","TagPopup_FormContainerBody1","TagPopup_FormContainerFooter1");
This is my shortcode function in wordpress plugin
$siteurl = "'" . home_url() . "'";
$close = 'javascript:TagPopup_HideForm("TagPopup_FormContainer1","TagPopup_FormContainerFooter1");';
$open = 'javascript:TagPopup_OpenForm("TagPopup_FormContainer1","TagPopup_FormContainerBody1","TagPopup_FormContainerFooter1");';
$html = "<a href='" . $open . "'><div class='login-user'>login</div></a>";
$html .= "<div style='display: none;' id='TagPopup_FormContainer1'>";
$html .= "<div id='TagPopup_FormContainerHeader'>";
$html .= '<div id="TagPopup_FormClose">' . __('X', 'tag-popup') . '</div>';
$html .= '<div id="TagPopup_FormTitle"> ' . __('', 'tag-popup') . wpautop(wp_kses_post($pull_atts['title']));
$html .= '</div>';
$html .= '</div>';
$html .= '<br><hr>';
$html .= '<div id="TagPopup_FormContainerBody1">';
$html .= '<form method="post" action="" name="single_form" id="id_single_Form" onsubmit="return validation_login(this)">';
$html .= '<div id="username-div">';
$html .= '<input name="username" class="username" type="text" id="id_username_login" Placeholder="Username" maxlength="120">';
$html .= '</div>';
$html .= '<div id="password-div">';
$html .= '<input name="password" class="password" type="password" id="id_password_login" Placeholder="Password" maxlength="120">';
$html .= '</div>';
$html .= '<div id="TagPopup_FormLabel_Page">';
$html .= '<input type="submit" name="login" class="login_submit" value="Login" >';
if (!is_home()) {
$html .= ' < Homepage';
}
$html .= 'New user?';
$html .= '</div>';
$html .= '</form>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div style="display: none;" id="TagPopup_FormContainerFooter1"></div>';
return $html;
}

Resources