Magento admin block does not appear - magento

I am experiencing very strange issue:
i have a module and it works in magento 1.4.0.0 - 1.7
recently i have someone that this module does not show in backend.
this the xml layout code
<reference name="content">
<block output="toHtml" type="syncer/adminhtml_mapping" template="wisepricer/mapping.phtml" name="wisepricer.mapping" />
</reference>
another peace of xml layout which goes to head - does appear.
i saw that it finds the block class (if you put die in the block constructor - it works).
But if you put die in the template - nothing. No logging about this.
the path to the template adminhtml/default/default/template/wisepricer/mapping.phtml
any ideas?
thanks
edit:
thanks for the reply guys, here is the additional info:
block declaration in config.xml
<blocks>
<syncer>
<class>Wisepricer_Syncer_Block</class>
</syncer>
</blocks>
part of the block class
<?php
/******************************************
* wisepricer *
******************************************/
class Wisepricer_Syncer_Block_Adminhtml_Mapping extends Mage_Adminhtml_Block_Template
{
function __construct() {
$this->setTemplate("wisepricer/mapping.phtml");
}
public function getHeader(){
$header = "Wisepricer Mapping";
return $header;
}
layout.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_syncer_mapping>
<reference name="head">
<action method="addItem"><type>skin_js</type> <name>wisepricer/prototype17.js</name></action>
<action method="addItem"><type>skin_js</type> <name>wisepricer/chosen.proto.js</name></action>
<action method="addCss"><stylesheet>wisepricer/wisepricer.css</stylesheet> </action>
<action method="addCss"><stylesheet>wisepricer/chosen.css</stylesheet> </action>
<action method="addItem"><type>skin_js</type> <name>wisepricer/chosen.proto.js</name></action>
</reference>
<reference name="content">
<block output="toHtml" type="syncer/adminhtml_mapping" template="wisepricer/mapping.phtml" name="wisepricer.mapping" />
</reference>
</adminhtml_syncer_mapping>
</layout>
template
<?php
$adminobj= new Mage_Adminhtml_Block_Template();
$formkey=$adminobj->getFormKey();
$licenseData=Mage::getModel('wisepricer_syncer/config')->load(1);
?>
<form id="mapping_form" name="mapping_form" method="post" action="<?php echo $this->getUrl('*/*/savemapping')?>">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
<input name="mapping_form[stock]" type="hidden" value="qty" />
<div class="top_block">
<div class="top_block_left">
<div class="inner-cont">
<img src="<?php echo $this->getSkinUrl('images/wisepricer/wp-logo.png'); ?>"/>
</div>
</div>
<div class="top_block_right">
<button class="wp-save-btn" onclick="return beforeSubmit()"></button>
</div>
</div>
<div class="mid_block">
<div class="mid_block_left">
<div class="guidelines">
<div class="guidelines-block">
<p><?php echo $this->__('Enter your WisePricer license key you received from WisePricer. This will link this store with your WisePricer account.')?></p>
</div>
<div class="guidelines-block import-guidelines">
<p><?php echo $this->__('Choose which products to import to WisePricer.')?></p>
</div>
<div class="guidelines-block mapping-guidelines">
<h4><?php echo $this->__('Wisepricer mapping guidelines:')?></h4>
<ul>
<li id="rule1"><?php echo $this->__('If you have <span class="field">UPC</span> or <span class="field">ASIN</span> then fields <span class="field">BRAND</span>,<span class="field">MODEL</span>,<span class="field">MPN</span> are not required.')?></li>
<li id="rule2"><?php echo $this->__('If you don\'t have <span class="field">UPC</span> or <span class="field">ASIN</span>, then you should have at least one of the following combinations: <span class="field">BRAND+MODEL</span> or <span class="field">BRAND+MPN</span>')?></li>
<li id="rule3"><?php echo $this->__('You must have either <span class="field">COST</span> or <span class="field">MINPRICE</span> or, you can set fixed rule for <span class="field">MINPRICE</span>')?></li>
<li><?php echo $this->__('<span class="field">NAME</span>, <span class="field">SKU</span>, and <span class="field">PRICE</span> fields are required')?></li>
<li><?php echo $this->__('Other fields are not required, but having them will increase your ability to interact with them within WisePricer(e.g. setting advanced rules, better matching and more)')?></li>
</ul>
</div>
</div>
</div>
<div class="mid_block_right">
<div class="values-block">
<div class="license-block">
<div class="label-block"><label><?php echo $this->__('Enter your License key')?> <span class="required">*</span></label></div>
<input type="text" value="<?php echo $licenseData->getLicensekey()?>" class="input-text required-entry" name="register_form[licensekey]" />
</div>
</div>
<div class="values-block">
<div class="license-block import-settings">
<div class="values-block-sub b10">
<div class="label-block"><label><?php echo $this->__('Import:')?></label></div>
<?php echo $this->renderWebsitesSelect($licenseData->getWebsite())?>
</div>
<div class="values-block-sub b10">
<div class="label-block"><label><?php echo $this->__('Product types:')?></label></div>
<?php echo $this->renderTypesSelect($licenseData->getProduct_type())?>
</div>
<div class="values-block-sub b10 check-block">
<div class="label-block b0"><label><?php echo $this->__('Do not import out of stock items')?></label></div>
<input type="checkbox" name="register_form[import_outofstock]" <?php echo $this->getImportOutStockSet();?>/>
</div>
<div class="values-block-sub check-block">
<div class="label-block b0"><label><?php echo $this->__('Reprice Configurable')?></label></div>
<input type="checkbox" name="register_form[reprice_configurable]" <?php if($licenseData->getReprice_configurable()){ echo 'checked';}?>/>
<p class="wptip"><?php echo $this->__('The Configurable product will be assigned to the price of his cheapest child')?></p>
</div>
</div>
</div>
<p><?php echo $this->__('Please make sure the following fields are assigned correctly:');?></p>
<div class="values-block">
<table cellspacing="0" class="form-list">
<tr class="t-header">
<td><strong><?php echo $this->__('Required Fields')?></strong></td><td><strong><?php echo $this->__('Detected field')?></strong></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('Title')?><span class="required">*</span></span></td>
<td class="input-ele"><?php echo $this->renderAttributesSelect('mapping_form[title]','title','name','required-entry chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('SKU')?><span class="required">*</span></span></td>
<td class="input-ele"><?php echo $this->renderSkuIdSelect('mapping_form[sku]','sku','sku','required-entry chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('UPC')?></span></td>
<td class="input-ele">
<?php echo $this->renderAttributesSelect('mapping_form[upc]','upc','upc','chzn-select')?>
</td>
<td class="desc"><p><span><?php echo $this->__('Universal Product Code')?></span></p></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('Brand')?></span></td>
<td class="input-ele"><?php echo $this->renderAttributesSelect('mapping_form[brand]','brand','brand','chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('Model')?></span></td>
<td class="input-ele"><?php echo $this->renderAttributesSelect('mapping_form[model]','model','model','chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('MPN')?></span></td>
<td class="input-ele"><?php echo $this->renderAttributesSelect('mapping_form[mpn]','mpn','mpn','chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('ASIN')?></span></td>
<td class="input-ele">
<?php echo $this->renderAttributesSelect('mapping_form[asin]','asin','asin','chzn-select')?>
</td>
<td class="desc"><p><span><?php echo $this->__('Amazon Standard Identification Number')?></span></p></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('Price')?> <span class="required">*</span></span></td>
<td class="input-ele"><?php echo $this->renderPriceAttributesSelect('mapping_form[price]','price','price','required-entry chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('Cost')?></span></td>
<td class="input-ele"><?php echo $this->renderAttributesSelect('mapping_form[cost]','cost','0','chzn-select')?></td>
<td></td>
</tr>
<tr>
<td class="label firstcol"><span><?php echo $this->__('Product image')?></span></td>
<td class="input-ele"><?php echo $this->renderAttributesSelect('mapping_form[productimage]','productimage','image','chzn-select')?></td>
<td></td>
</tr>
<tr class="special-opt-cont">
<td colspan="2">
<div class="ship-price-cont minprice">
<div class="ship-price-cont-top">
<div class="label"><?php echo $this->__('MinPrice')?></div>
<div class="value"><?php echo $this->renderAttributesSelect('mapping_form[minprice]','minprice','cost','chzn-select')?></div>
</div>
<div class="ship-price-cont-mid"><span><?php echo $this->__('-Or-')?></span></div>
<div class="ship-price-cont-bott">
<div class="label"><?php echo $this->__('Set a minimum price:')?></div>
</div>
<div class="ship-price-cont-bott desc">
<p><span><?php echo $this->__('this will manually override the choosen attribute.')?></span></p>
</div>
<div class="ship-price-cont-bott">
<div class="label">
<input id="minprice_man" type="text" name="mapping_form[minprice_man]" value="<?php echo $this->getFixedMinPrice()?>"/>
<?php echo $this->renderMinPriceRuleSelects();?>
</div>
</div>
</div>
</td>
<td class="desc"><p><span><?php echo $this->__('Wisepricer will never price below the minimum price you set.')?></span></p></td>
</tr>
<tr>
<td colspan="2">
<div class="ship-price-cont">
<div class="ship-price-cont-top">
<div class="label"><?php echo $this->__('Shipping price')?></div>
<div class="value"><?php echo $this->renderAttributesSelect('mapping_form[shipping]','shipping','0','chzn-select')?></div>
</div>
<div class="ship-price-cont-mid"><span><?php echo $this->__('-Or-')?></span></div>
<div class="ship-price-cont-bott">
<div class="label"><?php echo $this->__('Enter fixed shipping price')?></div>
<div class="value"><input type="text" name="mapping_form[shipping_man]" value="<?php echo $this->getShippingFixedRate()?>"/></div>
</div>
<div class="ship-price-cont-bott desc">
<p><span><?php echo $this->__('this will manually override the choosen attribute.')?></span></p>
</div>
</div>
</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
<div class="bott_block">
<div class="bott_block_left"></div>
<div class="bott_block_right">
<button class="wp-save-btn" onclick="return beforeSubmit()"></button>
</div>
</div>
</form>
<style>
#wsp-mapping td{
line-height: 20px;
overflow: hidden;
padding: 0 0 20px;
vertical-align: top;
width: 230px;
}
#wsp-mapping td.second-val{
padding-left: 20px
}
#wsp-mapping{
padding-top: 20px
}
</style>
<script type="text/javascript">
document.observe('dom:loaded', function(evt) {
var select, selects, _i, _len, _results;
if (Prototype.Browser.IE && (Prototype.BrowserFeatures['Version'] === 6 || Prototype.BrowserFeatures['Version'] === 7)) {
return;
}
selects = $$(".chzn-select");
_results = [];
for (_i = 0, _len = selects.length; _i < _len; _i++) {
select = selects[_i];
_results.push(new Chosen(select,{disable_search_threshold: 50}));
}
deselects = $$(".chzn-select-deselect");
for (_i = 0, _len = deselects.length; _i < _len; _i++) {
select = deselects[_i];
_results.push(new Chosen(select,{allow_single_deselect:true}));
}
return _results;
});
var editForm = new varienForm('mapping_form');
function beforeSubmit(){
$('rule2').setStyle('border:none');
$('rule1').setStyle('border:none');
$('rule3').setStyle('border:none');
var upc=$('upc').value;
var brand=$('brand').value;
var model=$('model').value;
var asin=$('asin').value;
var mpn=$('mpn').value;
var minprice=$('minprice').value;
var cost=$('cost').value;
var minprice_man=$('minprice_man').value;
var isValid=false;
var failedRule=0;
if(upc!=''||asin!=''){
if(minprice!=''||(cost!=''&&minprice_man!='')){
editForm.submit();
return;
}else{
failedRule=3;
}
}
if((brand!=''&&model!='')||(brand!=''&&mpn!='')){
if(minprice!=''||(cost!=''&&minprice_man!='')){
editForm.submit();
return;
}else{
failedRule=3;
}
}
if(failedRule==3){
$('rule3').setStyle('border:red solid 1px');
}else{
$('rule2').setStyle('border:red solid 1px');
$('rule1').setStyle('border:red solid 1px');
}
alert(Translator.translate('Please follow instructions in your mapping listed on the left.'));
window.location.hash='rule1';
return false;
}
</script>

Related

ajax only works once a refresh

I was doing a cart section where you can change your product quantity, at first i did it with a normal form, but i change it to ajax because i want to the page doesn´t need to refresh at all to show you your new quantity with your new price and your new total, so i did the following:
$('.actform').on('submit', function(ev) {
var id2 = $(this);
$.ajax({
type: $(id2).attr('method'),
url: $(id2).attr('action'),
data: $(id2).serialize(),
success: function(data) {
$('.container').load(' .container');
},
error: function() {
alert('Ha ocurrido un error');
}
});
ev.preventDefault();
});
It was all okay when you change 1 product for first time, but the second time the forms submits like it doesn´t have ajax, to fix this problem i replaced $('.container').load(' .container'); to $('.container').load(window.location.reload(false)); and it works, but i wanna know if there is another way to do it because this reload stutters a bit the page reload and it looks weird
cart.php whithout ajax (if you need to see):
<main id="main" class="main">
<?php if(!empty($_SESSION['cart'])){ ?>
<div class="container">
<h2 class="carrito-title">Mi Carrito</h2>
<div class="container2">
<div class="container-cart">
<table>
<thead>
<tr>
<th class="product-image">Imagen</th>
<th class="product-name">Producto</th>
<th class="product-price">Precio</th>
<th class="product-quantity">Cantidad (Modificar)</th>
<th class="product-total">Total</th>
<th class="product-remove">Eliminar</th>
</tr>
</thead>
<tbody>
<?php
$total= 0;
foreach($_SESSION['cart'] as $indice=>$producto){
$ID = $producto['ID'];
$select_products = $connect->prepare("SELECT * FROM `productos` WHERE id=$ID") or die('query failed');
$select_products->execute();
$list_products = $select_products->fetchAll(PDO::FETCH_ASSOC);
foreach($list_products as $product){
$nombre= $product['nombre'];
$precio= $product['precio'];
$codigo = $product['codigo'];
$imagen = "media/productos/$codigo.png";
?>
<tr>
<td class="product-image">
<img src="<?php echo $imagen?>" alt="<?php $nombre?>">
</td>
<td class="product-name">
<h2 class="name"><?php echo $nombre?></h2>
</td>
<td class="product-price"><h2 class="precio">$<?php echo number_format($precio, 0, ',', '.') ; ?></h2></td>
<td class="product-quantity">
<form action="backend/actProduct.php" method="post" class="actform" id="<?php echo $ID ?>">
<div class="cantidad">
<div class="cantidad-container">
<input type="hidden" name="id" min="1" value="<?php echo openssl_encrypt($ID,COD,KEY);?>">
<input type="number" class="nro updateCant" onchange="btnCart.click()" name="cantidadupd" value="<?php echo $producto['CANTIDAD'];?>">
<button name="btnCart" value="Update" type="submit" class="actualizar"><i class="fa-solid fa-rotate"></i></button>
</div>
</div>
</form>
</td>
<?php
$sub_total = $precio * $producto['CANTIDAD'];
$total = $total + $sub_total;
?>
<td><h2 class="subtotal">$<?php echo number_format($sub_total, 0, ',', '.'); ?></h2></td>
<td>
<form action="backend/deleteProduct.php" method="post">
<input type="hidden" name="id" value="<?php echo openssl_encrypt($ID,COD,KEY);?>">
<button class="delete" name="btnCart" type="submit" value="Remove" onclick="return confirm('Seguro que quieres eliminar este artículo?');">X</button>
</form>
</td>
</tr>
<?php
}};
?>
</tbody>
</table>
</div>
<?php if(isset($_SESSION['cart'])){ ?>
<div class="nocart">
<div class="final">
<h5 class="final-price preciofinal">Precio sin Impuestos: $<?php echo number_format($total, 0, ',', '.');?></h5>
<form action="backend/emptyCart.php" method="post" class="emptyform" id="<?php echo $ID ?>">
<input type="hidden" name="empty">
<button name="btnCart" type="submit" class ="vaciar" value="Empty" onclick="return confirm('¿Desea vaciar el carrito?');">Vaciar carrito</button>
</form>
</div>
<?php
if ($rol=='representante'){
?>
<div class="checkout">
<form action="productos.php">
<button name="btnFinCart" class="seguircomprando-btn">Seguir comprando</button>
</form>
<a class="checkout-btn" href="clientes.php">Seleccionar cliente</a>
</div>
<?php
}else{?>
<div class="checkout">
<form action="productos.php">
<button name="btnFinCart" class="seguircomprando-btn">Seguir comprando</button>
</form>
<form action="backend/fincompra.php" method="post" onsubmit="showLoad()">
<button name="btnFinCart" class ="checkout-btn" onclick="return confirm('¿Está seguro que desea finalizar la compra?');" value="Fin" >Finalizar compra</button>
</form>
</div>
<?php
}
?>
</div>
</div>
<?php }?>
</div>
<?php }else{
echo '
<div class="nosesion">
<h2 class="cartvacio">El carrito esta vacío</h2>
<a class="comprar-btn" href="productos.php">Comprar ahora</a>
</div>
';
}?>
</main>

Having problem with this form and the select option and also the email is not send

I want this form to send email but i don't work, i don'y know where is the problem but i think the problem is in the model, also this form has a select function i cannot make it work when i choose something in the select option to send it with email
This is the controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Offer extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('admin_model');
$this->load->helper(array('form', 'url', 'text'));
}
public function index() {
$this->load->view('header.php');
$this->load->view('offer.php');
$this->load->view('footer.php');
}
public function sendOffer(){
if(isset($_POST['companyname']) && isset($_POST['sendername']) && isset($_POST['email']) && isset($_POST['number']) && isset($_POST['interest']) && isset($_POST['message'])){
$data['companyname'] = $_POST['companyname'];
$data['sendername'] = $_POST['sendername'];
$data['email'] = $_POST['email'];
$data['number'] = $_POST['number'];
$data['interest'] = $_POST['interest'];
$data['message'] = $_POST['message'];
$data['created_at'] = date("Y-m-d H:i:s");
$this->admin_model->sendOfferEmail($data);
$this->db->insert('offer',$data);
$true = "Message Sent Successfully ...";
$this->session->set_flashdata('true', $true);
redirect(base_url()."offer");
}else{
$error = "Failed To Send, Please check all inputs and try again !!!";
$this->session->set_flashdata('error', $error);
redirect(base_url()."offer");
}
}
}
This is the model
public function sendOfferEmail($data){
$MailTo = "menna.ashour#thetranslationgate.com";
$subject = "The Translation Gate Website offer".$data['created_at'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
//$headers .= "Cc: amr.hussein#europelocalize.com". "\r\n";
$headers .= 'From: The Translation Gate Website'."\r\n";
$message = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Falaq| Site Manager</title>
<style>
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.428571429;
color: #333;
}
section#unseen
{
overflow: scroll;
width: 100%
}
</style>
<!--Core js-->
</head>
<body>
<div class="panel-body">
<div class="adv-table editable-table ">
<div class="clearfix">
<div class="btn-group">
<span class=" btn-primary" style="">
</span>
</div>
</div>
<div class="space15"></div>
<table class="table table-striped table-hover table-bordered" id="" style="overflow:scroll;border: 1px solid;width: 100%;text-align: center">
<tbody>
<tr>
<td style="background-color: #ddd;">Company Name</td>
<td style="background-color: #f9f9f9;">'.$data['companyname'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Full Name</td>
<td style="background-color: #f9f9f9;">'.$data['sendername'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Email</td>
<td style="background-color: #f9f9f9;">'.$data['email'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Phone Number</td>
<td style="background-color: #f9f9f9;">'.$data['number'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Message</td>
<td style="background-color: #f9f9f9;">'.$data['message'].'</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>';
mail($MailTo,$subject,$message,$headers);
}
public function getInterest($interest){
$result = $this->get_where('interest',array('id' => $interest))->row();
if(isset($result->name)){
return $result->name;
}else{
return '';
}
}
}
?>
This is the view
<section id="pageBar">
<div class="container">
<div class="row">
<h1 class="page-title pull-left">Offers</h1>
<ol class="breadcrumb pull-right">
<li>Home</li>
<li>Offers</li>
</ol>
</div>
</div>
</section>
<!-- Page-Bar -->
<!-- Login Form -->
<div id="login">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-offset-0">
<form class="login-form" method="post" action="<?=base_url()?>offer/sendOffer" enctype="multipart/form-data">
<div class="form-group input-block">
<label for="name">Company Name</label>
<input type="text" name="companyname" class="form-control" id="companyname" required>
</div>
<div class="form-group input-block">
<label for="name">Full Name</label>
<input type="text" name="sendername" class="form-control" id="sendername" required>
</div>
<div class="form-group input-block">
<label for="email" style="top: 24px; font-size: 16px;">Email</label>
<input type="email" name="email" class="form-control" id="email" required="" autocomplete="off">
</div>
<div class="form-group input-block">
<label for="name" style="top: 24px; font-size: 16px;">Phone Number</label>
<input type="text" name="number" class="form-control" id="number" required="" autocomplete="off">
</div>
<div class="select-group">
<select class="form-control selectpicker" >
<option disabled="disabled" selected="" value="">Interest</option>
<option value="1">Arabic</option>
<option value="2">DTP</option>
<option value="3">Both</option>
</select>
</div>
<div class="">
<textarea name="message" id="message" class="form-control" rows="6" placeholder="Message" required="" autocomplete="off"></textarea>
</div>
<div class="text-center">
<button type="submit" class="btn btn-gray">
Submit
</button>
</div>
</form> </div>
</div>
</div>
</div>
You have disabled to blank value the select box.So you are not able select.
Remove disabled="disabled" from select box.
For mail service turn on development mode and check the error you got.

Vuejs2 multiple if condition

I want to convert my php code into vuejs2 code as I'am changing my adminpanel as vue application(only ui).
I'am following this documentation, https://v2.vuejs.org/v2/guide/conditional.html
This is my art.vue component
<template>
<div class="col-md-8">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Latest Artworks</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body">
<div class="table-responsive">
<table class="table no-margin">
<thead>
<tr>
<th>ID</th>
<th>Art</th>
<th>Artist</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr v-for="item in art">
<td>
ART-{{ $art->.id }}
</td>
<td>{{ item.title }}</td>
<td>{{ item.artist.name }}</td>
<td>
<span class="label
<?php
if(item.status == "Pending")
echo 'label-warning';
elseif($art['status'] == "Approved")
echo 'label-success';
else
echo 'label-danger';
?>
">{{$art['status']}}</span> </td>
<td>
<div class="sparkbar" data-color="#00a65a" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="box-footer clearfix">
View All
</div>
</div>
</div>
</template>
<script>
export default {
computed : {
latest(){
return this.$store.state.art.latest
}
}
}
</script>
I have seen v-if condition statement, but in my case i have multiple conditions
I want to change this code
<span class="label
<?php
if($art['status'] == "Pending")
echo 'label-warning';
elseif($art['status'] == "Approved")
echo 'label-success';
else
echo 'label-danger';
?>
">{{$art['status']}}</span>
You can achieve multiple conditional views easily using v-else-ifs. Refer to the documentation here.
EDIT: Looking at the code sample it felt that there is no need for v-ifs. To add classes to an element can be done by the means of property binding.
<span class="label
<?php
if(item.status == "Pending")
echo 'label-warning';
elseif($art['status'] == "Approved")
echo 'label-success';
else
echo 'label-danger';
?>
">{{$art['status']}}</span>
can be written like:
<span :class='{label: true, "Pending": item.status === 'value', "label-warning": item.status === 'someOtherValue'}'>{{$art['status']}}</span>
in vuejs for the same effect, read more.
<span v-if="item.status === 'Pending'" class="label label-warning">
{{ item.status }}
</span>
<span v-else-if="item.status === 'Approved'" class="label label-success">
{{ item.status }}
</span>
<span v-else class="label label-danger">
{{ item.status }}
</span>
This solved my issue

Who can I automatically scroll to bottom of page on load in laravel

I want to scroll to bottom of the page on page-load automatically in laravel 5.2, i tried soo much but i couldn't figure out were i went wrong, I have attached my view code below.Can u go through it please and let me know were i went wrong. Actually i'm not good at design soo please help me on it.
my code:
#section('content')
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-3 col-sm-6 col-xs-12 profile_left">
<!-- start Support Tickets -->
<ul class="list-unstyled user_data">
<li>
<div class="panel panel-success">
<div class="panel-heading"><span class="glyphicon glyphicon-filter"></span><strong> Ticket Information</strong></div>
<div class="panel-body">
<!-- Modal -->
<table class="table table" style="color: #009933;">
#if(!empty($tickets))
<tr>
<td style="font-weight: bold; ">
<small>
{{$tickets->subject}}
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
#if ($tickets->status === 'open')
<span class="label label-success">{{$tickets->status}}</span>
#elseif ($tickets->status === 'ongoing')
<span class="label label-warning">{{$tickets->status}}</span>
#elseif ($tickets->status === 'closed')
<span class="label label-default">{{$tickets->status}}</span>
#endif
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
<p style="font-family: 'Times New Roman', Times, serif; ">Agent: {{\App\User::where('_id',$tickets->user_assigned)->value('username') }}</p>
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
<p style="font-family: 'Times New Roman', Times, serif; ">Priority:
#if ($tickets->priority === 'Low')
<span class="label label-info">{{$tickets->priority}}</span>
#elseif ($tickets->priority === 'Medium')
<span class="label label-primary">{{$tickets->priority}}</span>
#elseif ($tickets->priority === 'High')
<span class="label label-danger">{{$tickets->priority}}</span>
#endif</p>
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
<p style="font-family: 'Times New Roman', Times, serif; ">Last_Updated: {{$tickets->updated_at}}</p>
</small>
</td>
</tr>
#endif
</table>
</div>
</div>
</li>
<li>
<div class="panel panel-success">
<div class="panel-heading">
<span class="glyphicon glyphicon-dashboard"></span><strong> Support</strong>
</div>
<div class="panel-body">
<!-- Modal -->
<table class="table table-striped">
<tr>
<td><span class="glyphicon glyphicon-home"></span> My Support Tickets</td>
</tr>
<tr>
<td><span class="glyphicon glyphicon-open"></span> Submit Tickets</td>
</tr>
</table>
</div>
</div>
</li>
</ul>
<!-- end of Support Tickets -->
</div>
<div class="col-md-9 col-sm-9 col-xs-12">
<center>
<h2 style="color: #00BCD4;">My Ticket Feedback/<small>Your Comments History</small></h2>
</center>
<hr style="height:2px;border-width:0;color:gray;background-color:gray">
#if($tickets->status === 'closed')
#if(Auth::user()->_id === $tickets->user)
<div class="alert alert-warning" role="alert">
<center>
<p style="font-weight: bold; color:#FF9966; ">This Ticket is closed. You can reply to reopen this ticket.</p>
</center>
</div>
<div class="panel panel-success">
<div class="panel-heading">
<form action = "/reopentick/<?php echo $tickets->id; ?>" method = "post">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
<input type="hidden" name="status" value="open">
<span class="glyphicon glyphicon-pencil"></span>
<input type = 'submit' value = "Reply To Reopen Ticket" class="btn btn-link btn-xs" style="font-weight: bold; color:#009933; " />
<span class="glyphicon glyphicon-plus pull-right"></span>
</form>
</div>
</div>
#endif
#endif
<table class="table table-striped">
<tr><td>
<div class="panel-group">
#if($tickets->user == Auth::user()->_id)
<div class="panel panel-info">
#else
<div class="panel panel-success">
#endif
<div class="panel-heading">
<span class="glyphicon glyphicon-user">
<strong>
{{ \App\User::where('_id',$tickets->user)->value('username') }}
</strong>
</span>
<span class="glyphicon glyphicon-time pull-right">
{{ $tickets->created_at }}</br>
</span>
</div>
<div class="panel-body">
<p> Hello,</br>
{!! $tickets->message !!}</br>
<b>...</b></br>
Thank you,</br>
{{ \App\User::where('_id',$tickets->user)->value('username') }}
</p>
</div>
</div>
</div>
</td></tr>
<tr>
#foreach($anstickets as $t)
<td class="answer_block">
<div class="panel-group">
#if($t->user_id == Auth::user()->_id)
<div class="panel panel-info">
#else
<div class="panel panel-success">
#endif
<div class="panel-heading">
<span class="glyphicon glyphicon-user ">
<strong>
{{ \App\User::where('_id',$t->user_id)->value('username') }}
</strong>
</span>
<span class="glyphicon glyphicon-time pull-right">
{{ $t->created_at }}</br>
</span>
</div>
<div class="panel-body">
<p>Hi,</p>
{!!$t->comments!!}</br>
</div>
</div>
</div>
</td>
</tr>
#endforeach
</table>
#if(($tickets->status === 'ongoing')||($tickets->status === 'open'))
#if(Auth::user()->_id === $tickets->user)
<div class="panel panel-danger">
<div class="panel-heading">
<form action = "/closetick/<?php echo $tickets->id; ?>" method = "post" >
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
<input type="hidden" name="status" value="closed">
<input type = 'submit' value = "Close Ticket" class="btn btn-link btn-xs" style="font-weight: bold; color:#CC0000; "/>
<span class="glyphicon glyphicon-remove-sign pull-right"></span>
</form>
</div>
</div>
#endif
<br>
#if(Auth::user()->_id === $tickets->user)
<b><h1> Response</h1></b>
#else
<b><h1> Solution</h1></b>
#endif
<form action = "/tickanswert/<?php echo $tickets->id; ?>" method = "post" onsubmit="return form_submit()">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<input type="hidden" name="user_id" value="<?php echo Auth::user()->id; ?>">
<input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
<div class="form-group">
<textarea class="form-control" name="comments" rows="14" required></textarea>
</div>
<br>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" name="submit" class="btn btn-primary btn-lg">
<i class="fa fa-btn fa-ticket"></i> SUBMIT
</button>
</div>
</div>
</form>
#endif
</div>
</div>
#endsection
#section('additional-scripts')
<script>
$( document ).ready(function() {
$('html,body').animate({
scrollTop: $('.answer_block').children('.panel-group').last().offset().top},
'slow');
alert("Hello! I am an alert box!!");
});
</script>
#endsection
Laravel cannot scroll to bottom of page. But Javascript can:
<script>
$(document).ready(function() {
$('html,body').animate({scrollTop: document.body.scrollHeight},"slow");
})
</script>

What Script, Ajax , Controller codes are responsible for saving quantity

Below code we are using to display quantity text field and update quantity.
I want to know what all code is there in behind to update this quantity.
Means what script, ajax, contoller codes are responsible for saving this quantity.
<li class="fields">
<div class="customer-name">
<div class="field">
<label class="required" for="qty"><em>*</em><?php echo $helper->__('Quantity')?></label>
<div class="input-box">
<input type="text" name="qty" id="qty" value="<?php echo intval($mpAssignProductModel->getQty()) ?>" class="required-entry validate-zero-or-greater input-text"/>
</div>
</div>
</div>
</li>
because when i used above code in another file. It didt worked for me.
another page was displaying like this before :
After i replaced above code in another phtml file, its displaying like this :
This is complete code of file where updating quantity is not working :
phtml code :
<?php
$helper=Mage::helper('mpassignproduct');
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner();
if($isPartner==1){ ?>
<script type="text/javascript">
if (typeof jQuery == 'undefined'){
document.write(unescape("%3Cscript src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<div>
<div class="page-title">
<h1><?php echo $helper->__('My Assign Product List') ?></h1>
</div>
<div class="wk_mp_design">
<div class="block block-account">
<div class="block-title">
<strong><span><h4><?php echo $helper->__('My Assign Product List'); ?></h4></span></strong>
</div>
</div>
<div class="fieldset wk_mp_fieldset">
<div class="grid">
<div class="hor-scroll">
<?php
if(count($this->getCollection())==0): ?>
<div class="fieldset wk_mp_fieldset">
<div class="wk_emptymsg">
<?php echo $helper->__('No Product Available') ?>
</div>
</div>
<?php else: ?>
<form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post">
<table cellspacing="0" class="border wk_mp_list_table">
<thead>
<tr id="wk_mp_tr_heading">
<th><span><?php echo $helper->__('Product Name') ?></span></th>
<th><span><?php echo $helper->__('Date') ?></span></th>
<th><span><?php echo $helper->__('Product Status') ?></span></th>
<th><span> </span></th>
</tr>
</thead>
<tbody class="wk_mp_body">
<tr>
<td>
<input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/>
</td>
<td>
<span class="wk_mp_td_span">
<?php echo $helper->__('From: ') ?>
<input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" />
</span>
<span class="wk_mp_td_span">
<?php echo $helper->__('To: ') ?>
<input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" />
</span>
</td>
<td>
<select name="prostatus" class="input-text">
<option value=""><?php echo $helper->__('All') ?></option>
<option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>>
<?php echo $helper->__('Approved') ?>
</option>
<option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>>
<?php echo $helper->__('Unapproved') ?>
</option>
</select>
</td>
<td>
<button class="button" title="Save" type="submit">
<span><span><span><?php echo $helper->__('Submit') ?></span></span></span>
</button>
</td>
</tr>
</tbody>
</table>
</form>
<form name="formmassdelete" id="form-customer-product-delete" method="post" action="<?php echo $this->getUrl('mpassignproduct/index/massdeletepro') ?>">
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
<button id="mass_delete_butn" style="float: left;padding: 5px 5px 5px 0;" type="submit" title="Delete Sellers" class="button">
<span><span>Delete Products</span></span>
</button>
<table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table">
<thead>
<tr class="wk_content">
<th class="wk_check_first_td">
<span><input type="checkbox" id="mpselecctall" value="all" name="mpselecctall"></span>
</th>
<th class="wk_first_td">
<span class="label "><?php echo $helper->__('Product Name')?></span>
</th>
<th>
<span class="label name"><?php echo $helper->__('Price')?></span>
</th>
<th>
<span class="label name"><?php echo $helper->__('SKU')?></span>
</th>
<th>
<span class="label name"><?php echo $helper->__('Delivery Time')?></span>
</th>
<th>
<span class="label name"><?php echo $helper->__('Replacement Guarantee')?></span>
</th>
<th>
<span class="label qty"><?php echo $helper->__('Status')?></span>
</th>
<th>
<span class="label qty"><?php echo $helper->__('Qty.')?></span>
</th>
<th>
<span class="label qty"><?php echo $helper->__('Condition')?></span>
</th>
<th>
<span class="label"><?php echo $helper->__('Action')?></span>
</th>
</tr>
</thead>
<tbody>
<?php foreach($this->getCollection() as $assinproducts): ?>
<?php $products=Mage::getModel('catalog/product')->load($assinproducts->getProductId()); ?>
<tr class="wk_row_view ">
<td class="wk_check_first_td">
<span>
<input type="checkbox" value="<?php echo $assinproducts->getMpassignproductId(); ?>" class="mpcheckbox" name="product_mass_delete[]">
</span>
</td>
<td class="wk_first_td">
<span class="label name" title="<?php echo $products->getName(); ?>">
<?php
$productname=strlen($products->getName())>7?substr($products->getName(),0,7)."..":$products->getName();
echo $products->getName();
?>
</span>
</td>
<td>
<span class="label price">
<?php echo Mage::helper('core')->currency($assinproducts->getPrice(), true, false);?>
</span>
</td>
<td>
<span class="label sku">
<?php echo $assinproducts->getsku() ?>
</span>
</td>
<td>
<span class="label replacement">
<?php echo $assinproducts->getdeliverytime() ?>
</span>
</td>
<td>
<span class="label delivery">
<?php echo $assinproducts->getreplacement() ?>
</span>
</td>
<td>
<span class="label pro_status">
<?php if($assinproducts['flag']==1): ?>
<?php echo Mage::helper('mpassignproduct')->__('Approved')?>
<?php else: ?>
<?php echo Mage::helper('mpassignproduct')->__('Un-Approved')?>
<?php endif; ?>
</span>
</td>
<td>
<li class="fields">
<div class="customer-name">
<div class="field">
<label class="required" for="qty"><em>*</em><?php echo $helper->__('Quantity')?></label>
<div class="input-box">
<input type="text" name="qty" id="qty" value="<?php echo intval($mpAssignProductModel->getQty()) ?>" class="required-entry validate-zero-or-greater input-text"/>
</div>
</div>
</div>
</li>
</td>
<td>
<span class="label">
<?php
if($assinproducts['product_condition']=='new')
echo Mage::helper('mpassignproduct')->__('New');
else
echo Mage::helper('mpassignproduct')->__('Used');
?>
</span>
</td>
<td>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $assinproducts->getMpassignproductId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
<img data-type="<?php echo $assinproducts->getMpassignproductId(); ?>" src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</form>
<?php endif; ?>
</div>
</div>
<?php echo $this->getPagerHtml(); ?>
</div>
</div>
<div class="buttons-set">
<p class="back-link">
« <?php echo Mage::helper('marketplace')->__('Back') ?>
</p>
</div>
</div>
<?php }else{
echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>
<script>
function validateNumbers(e)
{
if (jQuery.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A, Command+A
(e.keyCode == 65 && ( e.ctrlKey === true || e.metaKey === true ) ) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
// let it happen, don't do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
}
var $wk_jq = jQuery.noConflict();
(function($wk_jq){
$wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq('#mpselecctall').click(function(event) {
if(this.checked) {
$wk_jq('.mpcheckbox').each(function() {
this.checked = true;
});
}else{
$wk_jq('.mpcheckbox').each(function() {
this.checked = false;
});
}
});
$wk_jq('body').delegate('.mp_edit','click',function(){
var id=$wk_jq(this).attr("data-type");
var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
if(dicision==true){
var $type_id=$wk_jq(this).attr('data-type');
window.location = "<?php echo $this->getUrl('mpassignproduct/index/edit/') ?>".concat("id/",id);
}
});
$wk_jq('.mp_delete').click(function(){
var id=$wk_jq(this).attr("data-type");
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
if(dicisionapp==true)
window.location = "<?php echo $this->getUrl('mpassignproduct/index/delete/') ?>".concat("id/",id);
});
$wk_jq('#mass_delete_butn').click(function(e){
var flag =0;
$wk_jq('.mpcheckbox').each(function(){
if (this.checked == true){
flag =1;
}
});
if (flag == 0){
alert("<?php echo $helper->__(' No Checkbox is checked') ?>");
return false;
}
else{
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
if(dicisionapp==true){
$wk_jq('#form-customer-product-delete').submit();
}else{
return false;
}
}
});
})($wk_jq);
function hideReset(product_id)
{
var qtyId='#qty_'+ product_id;
var editLink="#edit_link_"+ product_id;
var updateButton="#update_button_"+ product_id;
var resetButton="#reset_button_"+ product_id;
$wk_jq(qtyId).hide();
$wk_jq(editLink).show();
$wk_jq(updateButton).hide();
$wk_jq(resetButton).hide();
}
function showField(product_id)
{
var qtyId = '#qty_'+ product_id;
var editLink = "#edit_link_"+ product_id;
var updateButton = "#update_button_"+ product_id;
var resetButton = "#reset_button_"+ product_id;
$wk_jq(qtyId).show();
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(updateButton).prop('disabled', false);//just in case
$wk_jq(resetButton).show();
return false;
}
function updateField(product_id,assignqty)
{
// alert("Hello! I am an alert box!!");
var qtyId = '#qty_'+ product_id;
var valueId = '#valueqty_'+ product_id;
var updatedqty = '#updatedqty_'+ product_id;
var editLink = "#edit_link_"+ product_id;
var updateButton = "#update_button_"+ product_id;
var resetButton = "#reset_button"+ product_id;
var url = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>';
$wk_jq(qtyId).toggle();
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(resetButton).show();
$qty = $wk_jq(qtyId).val();
jQuery(valueId).html($qty);
hideReset(product_id);
var tmpQty = assignqty+parseInt($qty) ;
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, qty: tmpQty},
onComplete: function (transport) {
// alert(tmpQty);
jQuery(priceId).val($price);
jQuery(updatedqty).show().delay(2000).fadeOut();
$updateButton.prop('disabled', false);
}
});
}
</script>
Quantity is working in this file = http://pastebin.com/mByVn3ax

Resources