yii2-dynamicform. I can't update - yii2

I want to use dynamic form widget (wbraganca).
I tried it using the tutorial by 'doingItEasy' channel & also by github.
I can create and delete,but I can't update.:
Controller:
public function actionUpdate($id) {
$model = $this->findModel($id);
$modelsDentalist = $model->dentalists;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$oldIDs = ArrayHelper::map($modelsDentalist, 'id', 'id');
$modelsDentalist = Model::createMultiple(Dentalist::classname(), $modelsDentalist);
Model::loadMultiple($modelsDentalist, Yii::$app->request->post());
$deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsDentalist, 'id', 'id')));
$valid = $model->validate();
$valid = Model::validateMultiple($modelsDentalist) && $valid;
if ($valid) {
$transaction = \Yii::$app->db->beginTransaction();
try {
if ($flag = $model->save(false)) {
if (!empty($deletedIDs)) {
CalItem::deleteAll(['id' => $deletedIDs]);
}
foreach ($modelsDentalist as $modelDentalist) {
$modelDentalist->denta_id = $model->denta_id;
if (!($flag = $modelDentalist->save(false))) {
$transaction->rollBack();
break;
}
}
}
if ($flag) {
$transaction->commit();
return $this->redirect(['index']);
}
} catch (Exception $e) {
$transaction->rollBack();
}
}
} else {
return $this->render('update', [
'model' => $model,
'modelsDentalist' => (empty($modelsDentalist)) ? [new Dentalist] : $modelsDentalist
]);
}
}
_From.php
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use wbraganca\dynamicform\DynamicFormWidget;
use yii\helpers\ArrayHelper;
use app\models\School;
use app\models\Schoolclass;
use app\models\Schoolterm;
use app\models\Year;
use app\models\Dentalist;
<div class="denta-form">
<?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?>
<div class="row">
<div class="alert alert-success" role="alert">
<div class="row">
<div class="col-md-2">
<?=
$form->field($model, 'school_id')->dropDownList(
ArrayHelper::map(School::find()->andWhere('school_type_id in(1,2) ')->all(), 'school_id', 'school_name')
, ['prompt' => 'เลือกรายการ...'])
?>
</div>
<div class="col-md-2">
<?=
$form->field($model, 'school_term_id')->dropDownList(
ArrayHelper::map(Schoolterm::find()->all(), 'school_term_id', 'school_term_name')
, ['prompt' => 'เลือกรายการ...'])
?>
</div>
<div class="col-md-2">
<?=
$form->field($model, 'year')->dropDownList(
ArrayHelper::map(Year::find()->all(), 'year', 'year')
, ['prompt' => 'เลือกรายการ...'])
?>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-default">
<?php // <div class="panel-heading"><h4><i class="glyphicon glyphicon-envelope"></i> DentA list</h4></div> ?>
<div class="panel-body">
<?php
DynamicFormWidget::begin([
'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
'widgetBody' => '.container-items', // required: css class selector
'widgetItem' => '.item', // required: css class
'limit' => 4, // the maximum times, an element can be cloned (default 999)
'min' => 1, // 0 or 1 (default 1)
'insertButton' => '.add-item', // css class
'deleteButton' => '.remove-item', // css class
'model' => $modelsDentalist[0],
'formId' => 'dynamic-form',
'formFields' => [
'school_class_id',
'student_total',
'deciduous_caries',
'permanent_no',
'permanent_caries',
'gingivitis',
'disorder',
],
]);
?>
<div class="container-items"><!-- widgetContainer -->
<?php foreach ($modelsDentalist as $i => $modelDentalist): ?>
<div class="item panel panel-default"><!-- widgetBody -->
<div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button>
</div>
<div class="clearfix"></div>
<div class="panel-body">
<?php
//necessary for update action.
if (!$modelDentalist->isNewRecord) {
echo Html::activeHiddenInput($modelDentalist, "[{$i}]id");
}
?>
<div class="row">
<div class="col-sm-2">
<?=
$form->field($modelDentalist, "[{$i}]school_class_id")->dropDownList(
ArrayHelper::map(Schoolclass::find()
->where("school_class_id IN(1,2,3)")
->all(), 'school_class_id', 'school_class_name')
, ['prompt' => 'เลือกรายการ...'])
?>
</div>
<div class="col-sm-2">
<?= $form->field($modelDentalist, "[{$i}]student_total")->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-1">
<?= $form->field($modelDentalist, "[{$i}]deciduous_caries")->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-2">
<?= $form->field($modelDentalist, "[{$i}]permanent_no")->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-1">
<?= $form->field($modelDentalist, "[{$i}]permanent_caries")->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-2">
<?= $form->field($modelDentalist, "[{$i}]gingivitis")->textInput(['maxlength' => true]) ?>
</div>
<div class="col-sm-2">
<?= $form->field($modelDentalist, "[{$i}]disorder")->textInput(['maxlength' => true]) ?>
</div>
</div><!-- .row -->
</div>
</div>
<?php endforeach; ?>
</div>
<?php DynamicFormWidget::end(); ?>
</div>
</div>
</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
$script = <<< JS
JS;
$this->registerJs($script);
?>
</div>
Update.php
<?php
use yii\helpers\Html;
use app\models\DentaList;
/* #var $this yii\web\View */
/* #var $model app\models\Denta */
$this->title = Yii::t('app', 'Update {modelClass}: ', [
'modelClass' => 'Denta',
]) . $model->denta_id;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Dentas'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->denta_id, 'url' => ['view', 'id' => $model->denta_id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
?>
<div class="denta-update">
<h1><?= Html::encode($this->title) ?></h1>
<?=
$this->render('_form', [
'model' => $model,
'modelsDentalist' => $modelsDentalist,
])
?>
</div>
I can't update. Error:Getting unknown property: app\models\Dentalist::id

i think you can edit below line in Controller:
$oldIDs = ArrayHelper::map($modelsDentalist, 'denta_id', 'denta_id');
$modelsDentalist = Model::createMultiple(Dentalist::classname(), $modelsDentalist);
Model::loadMultiple($modelsDentalist, Yii::$app->request->post());
$deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsDentalist, 'denta_id', 'denta_id')));
and also edit line in _form:
echo Html::activeHiddenInput($modelDentalist, "[{$i}]denta_id");

Related

Custom filter and export filtered data into excel sheet not working in codeigniter

I have data table with search filed. I am trying to filter table using data range and order status. I want to filter table also using range and status and also want to export into excel sheet. Code is working for only search and simple export (Not filtered data).
Thanks
This is my file (View, Controller and Model)
View:-
<a class="pull-right btn btn-primary btn-xs" href="<?php echo base_url()?>order/createXLS"><i class="fa fa-file-excel-o"></i> Export Data</a>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title" >Custom Filter : </h3>
</div>
<div class="panel-body">
<form id="form-filter" method="POST" action="order/ajax_list" class="form-horizontal">
<div class="form-group">
<label for="FirstName" class="col-sm-2 control-label">From</label>
<div class="col-sm-4">
<input type="date" class="form-control" id="from">
</div>
</div>
<div class="form-group">
<label for="LastName" class="col-sm-2 control-label">To</label>
<div class="col-sm-4">
<input type="date" class="form-control" id="to">
</div>
</div>
<div class="form-group">
<label for="LastName" class="col-sm-2 control-label">Status</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="status">
</div>
</div>
<div class="form-group">
<label for="LastName" class="col-sm-2 control-label"></label>
<div class="col-sm-4">
<button type="button" id="btn-filter" class="btn btn-primary">Filter</button>
<button type="button" id="btn-reset" class="btn btn-default">Reset</button>
</div>
</div>
</form>
</div>
</div>
<table class="table table-bordered table-striped" id="mytable">
<thead>
<tr>
<th width="80px">No</th>
<th>Order Number</th>
<th>Service Date</th>
<th>Service Location</th>
<th>Customer Name</th>
<th>Contact Number</th>
<th>Order Status</th>
<th>Payment Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$start = 0;
foreach ($job_positions_data as $job_positions)
{
?>
<tr>
<td>
<?php echo ++$start ?>
</td>
<td>
<?php echo $job_positions->order_number ?>
</td>
<td>
<?php echo $job_positions->service_date ?>
</td>
<td>
<?php if($job_positions->service_location == 1)
{
echo 'vkool_branch';
}
else
{
echo 'customer_location' ;
}
?>
</td>
<td>
<?php echo $job_positions->firstname ?>
</td>
<td>
<?php echo $job_positions->contact_number ?>
</td>
<td>
<?php if($job_positions->order_status == 0)
{
echo 'Action Pending';
}
elseif($job_positions->order_status == 1)
{
echo 'Under Process' ;
}
elseif($job_positions->order_status == 2)
{
echo 'Cancelled' ;
}
elseif($job_positions->order_status == 3)
{
echo 'Completed' ;
}
elseif($job_positions->order_status == 4)
{
echo 'Refund' ;
}
?>
</td>
<td>
<?php if( $job_positions->payment_status == 1)
{
echo 'Pending (Pay at Store)';
}
elseif($job_positions->payment_status == 0)
{
echo 'Pending (Pay Online)';
}
elseif($job_positions->payment_status == 14)
{
echo 'Paid';
}?>
</td>
<td style="text-align:center" width="200px">
<i class="fa fa-search-plus"></i>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
$("#mytable").dataTable();
});
</script>
Controller : -
public function createXLS() {
$fileName = 'data-'.time().'.xlsx';
require_once APPPATH . "/third_party/PHPExcel/Classes/PHPExcel.php";
$orderInfo = $this->Order_model->get_For_Export();
$ordervalue = json_encode($orderInfo, true);
/*echo '<pre>';
print_r($orderInfo);
echo '</pre>';
exit;*/
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
// set Header
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'S.No');
$objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Order Number');
$objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Service Location');
$objPHPExcel->getActiveSheet()->SetCellValue('D1', 'First Name');
$objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Last Name');
$objPHPExcel->getActiveSheet()->SetCellValue('F1', 'Contact_No');
$objPHPExcel->getActiveSheet()->SetCellValue('G1', 'Order Status');
$objPHPExcel->getActiveSheet()->SetCellValue('H1', 'Payment Status');
// Style
$style = array(
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
),
'font' => array(
'bold' => true,
'color' => array('rgb' => '2F4F4F'),
'size' => 20,
),
);
$styleHeading = array(
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
),
'font' => array(
'bold' => true,
'size' => 15,
),
);
// set Row
$rowCount = 2;
foreach ($orderInfo as $element) {
$objPHPExcel->getActiveSheet()->SetCellValue('A' . $rowCount, $element['id']);
$objPHPExcel->getActiveSheet()->SetCellValue('B' . $rowCount, $element['order_number']);
$objPHPExcel->getActiveSheet()->SetCellValue('C' . $rowCount, $element['service_location']);
$objPHPExcel->getActiveSheet()->SetCellValue('D' . $rowCount, $element['firstname']);
$objPHPExcel->getActiveSheet()->SetCellValue('E' . $rowCount, $element['lastname']);
$objPHPExcel->getActiveSheet()->SetCellValue('F' . $rowCount, $element['contact_number']);
$objPHPExcel->getActiveSheet()->SetCellValue('G' . $rowCount, $element['order_status']);
$objPHPExcel->getActiveSheet()->SetCellValue('H' . $rowCount, $element['payment_status']);
$rowCount++;
}
// download file
$filename = "jobSummery". date("Y-m-d-H-i-s").".xls";
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
public function list_view()
{
$job_positions = $this->Order_model->get_all();
$data = array(
'job_positions_data' => $job_positions
);
$this->load->view('order/index', $data);
}
Model :-
public function get_all()
{
$this->db->order_by('id', 'DESC');
$this->db->from('tbl_order');
$query = $this->db->get();
$result = $query->result();
return $result;
}
public function get_For_Export()
{
$this->db->order_by('id', 'DESC');
$this->db->from('tbl_order');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}

Solving an Array error in codeigniter framework

I am trying to load my sign in page, but I get the error that:
Message: in_array() expects parameter 2 to be array, boolean given
Filename: views/sign_in.php
Line Number: 23(<?php if(in_array("ldap",$this->config->item("validation"))): ?>)
and in line 103 ..... where am I going wrong?
MY CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo lang('website_title')." : " .
lang('sign_in_page_name');
?></title>
<?php echo $this->load->view('meta'); ?>
<base href="<?php echo base_url(); ?>" />
<link type="text/css" rel="stylesheet"
href="resource/css/960gs/960gs.css"
/>
<link type="text/css" rel="stylesheet" href="resource/css/style.css" />
</head>
<body>
<?php echo $this->load->view('header'); ?>
<div id="content">
<div class="container_12">
<?php echo $this->load->view('logo'); ?>
<?php if(in_array("ldap",$this->config->item("validation"))): ?>
<div class="grid_12">
<h2><?php echo anchor(uri_string().($this->input-
>get('continue')?'/?continue='.urlencode($this->input-
>get('continue')):''), lang('sign_in_page_name')); ?></h2>
</div>
<div class="clear"></div>
<div id="ldap_validation" >
<?php echo form_open(uri_string()."/sign_in_ldap".($this->input-
>get('continue')?'/?continue='.urlencode($this->input-
>get('continue')):'')); ?>
<?php echo form_fieldset(); ?>
<h3><?php echo lang('windows_validation'); ?></h3>
<div class="grid_2 alpha">
<?php echo form_label(lang('sign_in_ldap_username'),
'sign_in_ldap_username'); ?>
</div>
<div class="grid_4 omega">
<?php echo form_input(array(
'name' => 'sign_in_ldap_username',
'id' => 'sign_in_ldap_username',
'value' => set_value('sign_in_ldap_username'),
'maxlength' => '255'
)); ?>
<?php echo form_error('sign_in_ldap_username'); ?>
<?php if (isset($sign_in_ldap_username_error)) : ?>
<span class="field_error"><?php echo
$sign_in_ldap_username_error; ?></span>
<?php endif; ?>
</div>
<div class="clear"></div>
<div class="grid_2 alpha">
<?php echo form_label(lang('sign_in_ldap_password'),
'sign_in_ldap_password'); ?>
</div>
<div class="grid_4 omega">
<?php echo form_password(array(
'name' => 'sign_in_ldap_password',
'id' => 'sign_in_ldap_password',
'value' => set_value('sign_in_ldap_password')
)); ?>
<?php echo form_error('sign_in_ldap_password'); ?>
</div>
<div class="clear"></div>
<?php if (isset($recaptcha)) : ?>
<div class="prefix_2 grid_4 alpha omega">
<?php echo $recaptcha; ?>
</div>
<?php if (isset($sign_in_recaptcha_error)) : ?>
<div class="prefix_2 grid_4 alpha omega">
<span class="field_error"><?php echo
$sign_in_recaptcha_error; ?></span>
</div>
<?php endif; ?>
<div class="clear"></div>
<?php endif; ?>
<div class="prefix_2 grid_4 alpha omega">
<span>
<?php echo form_button(array(
'type' => 'submit',
'class' => 'button',
'content' => lang('sign_in_ldap_sign_in')
)); ?>
</span>
<span>
<?php echo form_checkbox(array(
'name' => 'sign_in_ldap_remember',
'id' => 'sign_in_ldap_remember',
'value' => 'checked',
'checked' => $this-
>input>post('sign_in_ldap_remember'),
'class' => 'checkbox'
)); ?>
<?php echo form_label(lang('sign_in_ldap_remember_me'),
'sign_in_ldap_remember'); ?>
</span>
</div>
<div class="clear"></div>
<div class="prefix_2 grid_4 alpha omega">
<p><?php echo lang('sign_in_ldap_forgot_your_password'); ?>
<br />
<?php echo sprintf(lang('sign_in_ldap_dont_have_account'),
lang('sign_in_ldap_sign_up_now')); ?></p>
</div>
<div class="clear"></div>
<?php echo form_fieldset_close(); ?>
<?php echo form_close(); ?>
</div>
<?php endif; ?>
<?php if (in_array("simple",$this->config->item("validation"))): ?>
<div class="grid_12">
<?php if (in_array("ldap",$this->config-
>item("validation"))): ?>
<h2>Or</h2>
<?php else: ?>
<h2><?php echo anchor(uri_string().($this->input-
>get('continue')?'/?continue='.urlencode($this->input-
>get('continue')):''), lang('sign_in_page_name')); ?></h2>
<?php endif; ?>
</div>
<div class="clear"></div>
<div class="grid_6">
<?php echo form_open(uri_string().($this->input-
>get('continue')?'/?continue='.urlencode($this->input-
>get('continue')):'')); ?>
<?php echo form_fieldset(); ?>
<h3><?php echo lang('sign_in_heading'); ?></h3>
<?php if (isset($sign_in_error)) : ?>
<div class="grid_6 alpha omega">
<div class="form_error"><?php echo $sign_in_error; ?></div>
</div>
<div class="clear"></div>
<?php endif; ?>
<div class="grid_2 alpha">
<?php echo form_label(lang('sign_in_username_email'),
'sign_in_username_email'); ?>
</div>
<div class="grid_4 omega">
<?php echo form_input(array(
'name' => 'sign_in_username_email',
'id' => 'sign_in_username_email',
'value' => set_value('sign_in_username_email'),
'maxlength' => '24'
)); ?>
<?php echo form_error('sign_in_username_email'); ?>
<?php if (isset($sign_in_username_email_error)) : ?>
<span class="field_error"><?php echo
$sign_in_username_email_error; ?></span>
<?php endif; ?>
</div>
<div class="clear"></div>
<div class="grid_2 alpha">
<?php echo form_label(lang('sign_in_password'),
'sign_in_password'); ?>
</div>
<div class="grid_4 omega">
<?php echo form_password(array(
'name' => 'sign_in_password',
'id' => 'sign_in_password',
'value' => set_value('sign_in_password')
)); ?>
<?php echo form_error('sign_in_password'); ?>
</div>
<div class="clear"></div>
<?php if (isset($recaptcha)) : ?>
<div class="prefix_2 grid_4 alpha omega">
<?php echo $recaptcha; ?>
</div>
<?php if (isset($sign_in_recaptcha_error)) : ?>
<div class="prefix_2 grid_4 alpha omega">
<span class="field_error"><?php echo
$sign_in_recaptcha_error; ?></span>
</div>
<?php endif; ?>
<div class="clear"></div>
<?php endif; ?>
<div class="prefix_2 grid_4 alpha omega">
<span>
<?php echo form_button(array(
'type' => 'submit',
'class' => 'button',
'content' => lang('sign_in_sign_in')
)); ?>
</span>
<span>
<?php echo form_checkbox(array(
'name' => 'sign_in_remember',
'id' => 'sign_in_remember',
'value' => 'checked',
'checked' => $this->input-
>post('sign_in_remember'),
'class' => 'checkbox'
)); ?>
<?php echo form_label(lang('sign_in_remember_me'),
'sign_in_remember'); ?>
</span>
</div>
<div class="clear"></div>
<div class="prefix_2 grid_4 alpha omega">
<p><?php echo anchor('account/forgot_password',
lang('sign_in_forgot_your_password')); ?><br />
<?php echo sprintf(lang('sign_in_dont_have_account'),
anchor('account/sign_up', lang('sign_in_sign_up_now'))); ?></p>
</div>
<div class="clear"></div>
<?php echo form_fieldset_close(); ?>
<?php echo form_close(); ?>
</div>
<div class="grid_6">
<h3><?php echo sprintf(lang('sign_in_third_party_heading')); ?>
</h3>
<ul>
<?php foreach($this->config-
>item('third_party_auth_providers') as $provider) : ?>
<li class="third_party <?php echo $provider; ?>"><?php echo
anchor('account/connect_'.$provider, lang('connect_'.$provider),
array('title'=>sprintf(lang('sign_in_with'),
lang('connect_'.$provider)))); ?></li>
<?php endforeach; ?>
</ul>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<?php endif; ?>
</div>
<?php echo $this->load->view('footer'); ?>
</body>
</html>
The error message is:
Severity: Warning
Message: in_array() expects parameter 2 to be array, boolean given
Filename: views/sign_in.php
Line Number: 23
High chances that $this->config->item("validation") is a boolean, but you are trying to find strings 'simple' and 'ldap' inside it like in array.
This is, probably, your problem, but I can't really help solving it, because I don't quite understand what are you trying to achieve with this code.
<?php if (in_array("simple",$this->config->item("validation"))): ?>
<?php if(in_array("ldap",$this->config->item("validation"))): ?>

Button in every row in dynamic form yii2

I'm using yii2 dynamic form to collect data. Within the dynamic form, I want a button in each row. And on click of it, It'll call a javascript function to take fingerprint and put it in the image. The button is showing good for the first row, but from second row, It's not properly coming up.
Secondly when I click on the Click here to Scan button, it takes the fingerprint and put it in the first row.
How can I solve this 2 issue.
The Code I'm using in this form is -
<div class="row">
<div class="col-xs-12 col-sm-12 col-lg-12">
<div class="panel panel-default">
<div class="panel-heading"><h4><i class="glyphicon glyphicon-envelope"></i> Crew Members</h4></div>
<div class="panel-body">
<?php DynamicFormWidget::begin([
'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
'widgetBody' => '.container-items', // required: css class selector
'widgetItem' => '.item', // required: css class
'limit' => 200, // the maximum times, an element can be cloned (default 999)
'min' => 1, // 0 or 1 (default 1)
'insertButton' => '.add-item', // css class
'deleteButton' => '.remove-item', // css class
//'scanButton' => '.scan-item',
'model' => $modelsProductsales[0],
'formId' => 'dynamic-form',
'formFields' => [
//'wpc_wpno',
'wpc_crewid',
'wpc_crewname',
'wpc_auth',
],
]); ?>
<div class="container-items"><!-- widgetContainer -->
<?php foreach ($modelsProductsales as $i => $modelsProductsales): ?>
<div class="item panel panel-default"><!-- widgetBody -->
<div class="panel-body">
<?php
// necessary for update action.
if (! $modelsProductsales->isNewRecord) {
echo Html::activeHiddenInput($modelsProductsales, "[{$i}]wpc_id");
}
?>
<div class="row-fluid">
<div class="form-group">
<div class="col-xs-4 col-sm-4 col-lg-4 nopadding">
<div class="col-xs-12 col-sm-12 col-lg-12 nopadding" >
<?= $form->field($modelsProductsales, "[{$i}]wpc_crewid")->label(false)->textInput(['maxlength' => true,'placeholder' => 'Crew ID No','autocomplete' => 'off','onchange' => 'getCrewName($(this));','onkeyup' => 'getCrewName($(this));','class' => 'crewid']) ?>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 nopadding" >
<?= $form->field($modelsProductsales, "[{$i}]wpc_crewname")->label(false)->textInput(['maxlength' => true,'placeholder' => 'Crew Name','readOnly'=>true]) ?>
</div>
</div>
</div>
<div class="col-xs-5 col-sm-5 col-lg-5 nopadding">
<div align="center">
<div class="col-xs-12 col-sm-12 col-lg-12 nopadding" >
<img id="FPImage1-<?= $i ?>-image" alt="Fingerpint Image" height=100 width=95 align="center" src="/images/PlaceFinger.bmp"> <br>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 nopadding" >
<div class="col-xs-6 col-sm-6 col-lg-6 nopadding" >
<input type="[{$i}]button" class="btn btn-success btn-xs" value="Click to Scan" onclick="CallSGIFPGetData(SuccessFunc1, ErrorFunc)"><br>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 nopadding" >
<input type="[{$i}]button" class="btn btn-success btn-xs" value="Click here to Verify" onclick="matchScore(succMatch, failureFunc)"><br>
</div>
</div>
</div>
</div>
<div class="col-xs-2 col-sm-2 col-lg-2 nopadding" >
<?= $form->field($modelsProductsales, "[{$i}]wpc_auth")->label(false)->textInput(['maxlength' => true,'placeholder' => 'Verification','readOnly'=>true]) ?>
</div>
<div class="col-xs-1 col-sm-1 col-lg-1 nopadding">
<div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs" onClick="workmanPlus()"><i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs" onClick="workmanMinus()"><i class="glyphicon glyphicon-minus"></i></button>
</div>
</div>
</div>
</div><!-- .row -->
</div>
</div><!-- item panel default -->
<?php endforeach; ?>
</div><!-- container item -->
<?php DynamicFormWidget::end(); ?>
</div><!-- panel body -->
</div><!-- panel default -->
</div><!-- outer row -->
</div>
<div class="row">
<div class="form-group">
<div class="col-xs-12 col-sm-12 col-lg-12">
<h2><center><u>Select Safety Precaution Taken : Operations</u></center></h2>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-xs-10 col-sm-10 col-lg-10">
<?= $form->field($model, 'wp_pt1')->textInput(['maxlength' => true,'readOnly'=>true])->label(false) ?>
</div>
<div class="col-xs-2 col-sm-2 col-lg-2">
<div class="form-inline">
<? $model->wp_ptst1 = 'Yes'; ?>
<?= $form->field($model, 'wp_ptst1')->radioList(['Yes'=>'Yes','No'=>'No','NA'=>'NA'])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-xs-10 col-sm-10 col-lg-10">
<?= $form->field($model, 'wp_pt2')->textInput(['maxlength' => true,'readOnly'=>true])->label(false) ?>
</div>
<div class="col-xs-2 col-sm-2 col-lg-2">
<div class="form-inline">
<? $model->wp_ptst2 = 'Yes'; ?>
<?= $form->field($model, 'wp_ptst2')->radioList(['Yes'=>'Yes','No'=>'No','NA'=>'NA'])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-xs-10 col-sm-10 col-lg-10">
<?= $form->field($model, 'wp_pt3')->textInput(['maxlength' => true,'readOnly'=>true])->label(false) ?>
</div>
<div class="col-xs-2 col-sm-2 col-lg-2">
<div class="form-inline">
<? $model->wp_ptst3 = 'Yes'; ?>
<?= $form->field($model, 'wp_ptst3')->radioList(['Yes'=>'Yes','No'=>'No','NA'=>'NA'])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-xs-10 col-sm-10 col-lg-10">
<?= $form->field($model, 'wp_pt4')->textInput(['maxlength' => true,'readOnly'=>true])->label(false) ?>
</div>
<div class="col-xs-2 col-sm-2 col-lg-2">
<div class="form-inline">
<? $model->wp_ptst4 = 'Yes'; ?>
<?= $form->field($model, 'wp_ptst4')->radioList(['Yes'=>'Yes','No'=>'No','NA'=>'NA'])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12">
<div class="form-group pull-right">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Submit', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-success']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
/* start getting the itemid */
$script = <<< JS
function workmanPlus() {
var workMen = $(".wmn").val();
workMen++;
//alert(workMen);
$(".wmn").val(workMen);
}
JS;
$this->registerJs($script, View::POS_END);
/* end getting the itemid */
?>
<?php
/* start getting the itemid */
$script = <<< JS
function workmanMinus() {
var workMen = $(".wmn").val();
workMen--;
//alert(workMen);
$(".wmn").val(workMen);
}
JS;
$this->registerJs($script, View::POS_END);
/* end getting the itemid */
?>
<?php
/* start getting the crew name and template 2 details */
$script = <<< JS
function getCrewName(item) {
var index = item.attr("id").replace(/[^0-9.]/g, "");
var product = 0;
var id = item.attr("id");
var myString = id.split("-").pop();
product = item.val();
//alert(product);
$.get('index.php?r=workpermit/workpermit/get-for-crewdetails',{ prodname : product }, function(data){
//alert(data);
var data = $.parseJSON(data);
var getItemid = data;
itemID = "wpcrew-".concat(index).concat("-wpc_crewname");
template_2 = getItemid["cr_pw1"];
//alert(template_2);
$("#"+itemID+"").val(getItemid["cr_name"]);
});
}
JS;
$this->registerJs($script, View::POS_END);
/* end getting the item details */
?>
<script type="text/javascript">
var template_1 = "";
function SuccessFunc1(result) {
if (result.ErrorCode == 0) {
/* Display BMP data in image tag
BMP data is in base 64 format
*/
if (result != null && result.BMPBase64.length > 0) {
document.getElementById('FPImage1-<?= $i ?>-image').src = "data:image/bmp;base64," + result.BMPBase64;
}
template_1 = result.TemplateBase64;
}
else {
alert("Fingerprint Capture Error Code: " + result.ErrorCode + ".\nDescription: " + ErrorCodeToString(result.ErrorCode) + ".");
}
}
function ErrorFunc(status) {
/*
If you reach here, user is probabaly not running the
service. Redirect the user to a page where he can download the
executable and install it.
*/
alert("Check if SGIBIOSRV is running; status = " + status + ":");
}
function CallSGIFPGetData(successCall, failCall) {
var secugen_lic = "";
var uri = "https://localhost:8443/SGIFPCapture";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
fpobject = JSON.parse(xmlhttp.responseText);
successCall(fpobject);
}
else if (xmlhttp.status == 404) {
failCall(xmlhttp.status)
}
}
xmlhttp.onerror = function () {
failCall(xmlhttp.status);
}
var params = "Timeout=" + "10000";
params += "&Quality=" + "50";
params += "&licstr=" + encodeURIComponent(secugen_lic);
params += "&templateFormat=" + "ISO";
xmlhttp.open("POST", uri, true);
xmlhttp.send(params);
}
function matchScore(succFunction, failFunction) {
var idQuality = 100;
//alert(template_2);
//alert("matchscore is called!");
//alert("Template 1 = " + template_1 + " & Template 2 = " + template_2);
if (template_1 == "" || template_2 == "") {
alert("Please scan finger again!!");
return;
}
var uri = "https://localhost:8443/SGIMatchScore";
var secugen_lic = "";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
fpobject = JSON.parse(xmlhttp.responseText);
succFunction(fpobject);
}
else if (xmlhttp.status == 404) {
failFunction(xmlhttp.status)
}
}
xmlhttp.onerror = function () {
failFunction(xmlhttp.status);
}
var params = "template1=" + encodeURIComponent(template_1);
params += "&template2=" + encodeURIComponent(template_2);
params += "&licstr=" + encodeURIComponent(secugen_lic);
params += "&templateFormat=" + "ISO";
xmlhttp.open("POST", uri, false);
xmlhttp.send(params);
}
function succMatch(result) {
//var idQuality = document.getElementById("quality").value;
var idQuality = 100;
if (result.ErrorCode == 0) {
if (result.MatchingScore >= idQuality){
alert("MATCHED Found!");
//verification = "Verified";
//verification = "wpcrew-".concat(index).concat("-wpc_auth");
document.getElementById('wpcrew-<?= $i ?>-wpc_auth').value = "Verified";
//break loopedfunction;
}
else
alert("NOT MATCHED !");
}
else {
alert("Error Scanning Fingerprint ErrorCode = " + result.ErrorCode);
}
}
function failureFunc(error) {
alert ("On Match Process, failure has been called");
}
</script>
After implementing Vandro's solution -
The button values are showing in every row.
But on clicking "Click to scan" in the second row, it's scanning and passing the value to the first row image.
Also, On click on "Click to scan" the form is trying to get submitted.
Try this:
change how you call your image for way this:
<?= \yii\bootstrap\Html::img('/images/PlaceFinger.bmp', [
'id'=>"FPImage-0-image",
'alt' => 'Fingerpint Image',
'height'=>'100',
'width'=>'95',
'align'=>"center"
]) ?>
and change your bottoms to this:
<div class="col-xs-12 col-sm-12 col-lg-12 nopadding">
<div class="col-xs-6 col-sm-6 col-lg-6 nopadding">
<?= yii\bootstrap\Button::widget([
'label' => "Click to Scan",
'options' => [
'id' => "btnCallSGIFPGetData",
'class' => 'btn btn-success btn-xs',
'onclick' => "CallSGIFPGetData(SuccessFunc1, ErrorFunc)"
],
]);
?>
</div>
<div class="col-xs-6 col-sm-6 col-lg-6 nopadding">
<?= yii\bootstrap\Button::widget([
'label' => "Click here to Verify",
'options' => [
'id' => 'btnMatchScore',
'class' => 'btn btn-success btn-xs',
'onclick' => "matchScore(succMatch, failureFunc)"
],
]);
?>
</div>
</div>
then let me know your progress to see on what else can i help
UPDATE
first change the button id for something like:
'id' => "btn-0-CallSGIFPGetData",
on your onclick send your button to with $(this):
'onclick' => "CallSGIFPGetData(SuccessFunc1, ErrorFunc, $(this))"
then edit your CallSGIFPGetData function to be like:
function CallSGIFPGetData(successCall, failCall, btn)
then on your successCall inside CallSGIFPGetData send the button Id to:
successCall(fpobject, btn.attr('id'));
and then edit your SuccessFunc1 function to be like:
function SuccessFunc1(result, btnId)
then inside the SuccessFunc1 function get your index:
var index=btnId.split('-')[1].split('-')[0];
and placed on:
document.getElementById('FPImage-'+index+'-image').src...
hope it works

Cakephp Form Helper Input's label to place outside of the div

I've googled and only found before after answer to get this done but that does not fit my problem. I want to move default label element outside of the div.
<?php echo $this->Form->input('name', array( 'before' => $this->Form->label('Subject:'), 'class' => 'form-control', 'div' => 'col-md-9 col-sm-9 col-xs-12')); ?>
Output is
<div class="col-md-9 col-sm-9 col-xs-12 required">
<label for="StaffSubject:">Subject:</label>
<input name="data[Staff][name]" class="form-control" maxlength="255" type="text" id="StaffName" required="required">
</div>
But I want this output instead
<label for="StaffSubject:">Subject:</label>
<div class="col-md-9 col-sm-9 col-xs-12 required">
<input name="data[Staff][name]" class="form-control" maxlength="255" type="text" id="StaffName" required="required">
</div>
the best solution for that is to remove the label from your input and added before your input
<?php echo $this->Form->label('Subject:');
echo $this->Form->input('name', array(
'label' => false,
'class' => 'form-control',
'div' => 'col-md-9 col-sm-9 col-xs-12'
)); ?>
This should work:
<?php echo $this->Form->input('name', array(
'label'=>'Subject',
'class' => 'form-control',
'wrapInput' => 'col-md-9 col-sm-9 col-xs-12',
)); ?>

Moving Details box renders Add to Cart Button inoperable - Magento

My site offers products that have multiple options. Some with as many as 5-8 options. So, the "details box" ends up way beneath all of the options. Also, the details are to long to place into the "short description" box at the top. So, I moved the details box above the options box. When doing this it causes the "add to cart" button to no longer work. I have tried moving code all over the page & no matter which portion of code I move the "add to cart button" won't work. (I have tried moving the options code & the details box code) I am using a custom theme called BuyShop. Here is a link to one of the products so you can see what I am talking about & trying to do: http://www.dvineinspiration.com/featured-products/mime-basic-plus.html. I have also included the code from the product/view.phtml file below.
<!--PRODUCT BOX-->
<?php
$widthSmall=62;
$heightSmall=62;
$widthMedium=460;
$heightMedium=440;
$_video = $this->getProduct()->getVideobox();
$_customtab = $this->getProduct()->getCustomtab();
$_customtabtitle = $this->getProduct()->getCustomtabtitle();
$image_size=Mage::getStoreConfig('buyshoplayout/product_info/product_info_image_size');
$main_image_popup='';
$popup_video='';
if(Mage::helper('lightboxes')->isActive())
{
/*popups*/
$helper = Mage::helper('lightboxes');
$rel = $helper->getLightboxRel($helper->getConfig('lightbox_type'));
$class = $helper->getLightboxClass($helper->getConfig('lightbox_type'));
$main_image_popup='class="'.$class.'" rel="'.$rel.'"';
$popup_video='class="video '.$class.'" rel="'.$rel.'"';
}
switch($image_size)
{
case 'small':
if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video))
{
$span0=4;
$span1=1;
$span2=3;
$span3=8;
}
else
{
$span0=3;
$span1=1;
$span2=3;
$span3=9;
}
$height_thumbs=206;
break;
case 'medium':
if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video))
{
$span0=5;
$span1=1;
$span2=4;
$span3=7;
}
else
{
$span0=4;
$span1=1;
$span2=4;
$span3=8;
}
$height_thumbs=350;
break;
case 'big':
if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video))
{
$span0=6;
$span1=1;
$span2=5;
$span3=6;
}else
{
$span0=5;
$span1=1;
$span2=5;
$span3=7;
}
$height_thumbs=422;
break;
}
?>
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div class="product-box">
<div class="no-display">
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
</div>
<div class="row">
<div class="span<?php echo $span0?>">
<div class="product-img-box">
<div class="row">
<?php if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video)):?>
<div class="span<?php echo $span1?>">
<div class="more-views flexslider">
<ul class="slides">
<?php echo $this->getChildHtml('media') ?>
<?php if(!empty($_video)):?>
<li><a class="video" href="<?php echo Mage::helper('catalog/output')->productAttribute($this->getProduct(), $_video, 'video') ?>"><i class=" icon-link"></i></a></li>
<?php endif;?>
</ul>
</div>
</div>
<?php endif;?>
<div class="span<?php echo $span2?>">
<div class="product-image">
<a <?php echo $main_image_popup;?> title="<?php echo $this->htmlEscape($_product->getImageLabel())?>" <?php if(!Mage::helper('lightboxes')->isActive()):?>class="cloud-zoom"<?php endif;?> href="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_product->getFile())?>" <?php if(!Mage::helper('lightboxes')->isActive()):?>id='zoom1' data-rel="position: 'right', adjustX: 10, adjustY: 0"<?php endif;?>>
<img class="product-retina" data-image2x="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_product->getFile())->resize($widthMedium*2, $heightMedium*2)?>" src="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_product->getFile())->resize($widthMedium, $heightMedium)?>" alt="" />
</a>
</div>
<div class="pull-right hidden"><i class="icon-zoom-in"></i></div>
</div>
</div>
</div>
</div>
<div class="span<?php echo $span3?>">
<div class="product-shop">
<?php echo $this->getChildHtml('custom_related_block') ?>
<div class="product_info_left">
<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>
<?php if(Mage::getStoreConfig('buyshoplayout/product_info/sku')):?>
<p><?php echo $this->__('SKU') ?>: <b><?php echo nl2br($_product->getSku()) ?></b></p>
<?php endif; ?>
<?php if(!Mage::getStoreConfig('buyshopconfig/options/catalog_mode')):?>
<div class="product_type_data_price"><?php echo $this->getChildHtml('product_type_data') ?></div>
<?php endif; ?>
<div class="share-buttons share-buttons-panel" data-style="medium" data-counter="true" data-oauth="true" data-hover="true" data-promo-callout="left" data-buttons="twitter,facebook,pinterest"></div></p>
<div class="add-to-links">
<ul>
<?php echo Mage::helper('buyshopconfig')->addWishCompLink($_product,$this,true); ?>
<?php if ($this->canEmailToFriend()): ?>
<li><i class="icon-at"></i><?php echo $this->__('Email to a friend') ?></li>
<?php endif; ?>
</ul>
</div>
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
<?php if(!Mage::getStoreConfig('buyshopconfig/options/catalog_mode')):?>
<?php echo $this->getPriceHtml($_product) ?>
<?php endif; ?>
<div class="socialsplugins_wrapper">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('buyshop_social_like_buttons')->toHtml() ?>
</div>
<?php if ($_product->getShortDescription()):?>
<div class="short-description"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
<?php endif;?>
<?php echo Mage::helper('buyshopconfig')->countdownSpecialPrice($_product,'defaultCountdown',$this);?>
<?php if(!Mage::getStoreConfig('buyshopconfig/options/catalog_mode')):?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
<?php if (!$this->hasOptions()):?>
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php endif; ?>
<?php echo $this->getChildHtml('extra_buttons') ?>
<?php endif; ?>
<?php endif; ?>
<?php echo $this->getChildHtml('other');?>
<?php if(Mage::getStoreConfig('buyshoplayout/product_info/qr')):?>
<div class="clearfix hidden-phone" style="margin: 20px 0 0 0">
<img src="http://api.qrserver.com/v1/create-qr-code/?size=100x100&data=<?php echo Mage::helper("core/url")->getCurrentUrl() ?>" alt="QR: <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>"/>
</div>
<?php endif;?>
</div>
</div>
</div>
<?php $modules_enable=Mage::getStoreConfig('advanced/modules_disable_output');?>
<div class="row">
<div class="span12">
<ul class="nav-tabs" id="myTab">
<li class="active"><?php echo $this->__('Description') ?></li>
<?php if(!$modules_enable['Mage_Review']):?><li><?php echo $this->__('Reviews') ?></li><?php endif;?>
<?php if(!$modules_enable['Mage_Tag']):?><li><?php echo $this->__('Tags') ?></li><?php endif;?>
<?php if ($_customtab && Mage::getStoreConfig('buyshoplayout/product_info/custom_tab')): ?>
<li><?php if(!empty($_customtabtitle)) echo html_entity_decode($this->helper('catalog/output')->productAttribute($this->getProduct(), $_customtabtitle, 'customtabtitle'));else echo 'Custom tab title' ?></li>
<?php endif;?>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
<div class="box-collateral <?php echo "box-{$alias}"?>">
<?php if ($title = $this->getChildData($alias, 'title')):?>
<h2><?php echo $this->escapeHtml($title); ?></h2>
<?php endif;?>
<?php echo $html; ?>
</div>
<?php endforeach;?>
</div>
<div class="tab-pane" id="tab2">
<?php echo $this->getChildHtml('reviews') ?>
</div>
<div class="tab-pane" id="tab3">
<?php echo $this->getChildHtml('product_additional_data') ?>
</div>
<?php if ($_customtab): ?>
<div class="tab-pane" id="tab4">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_customtab, 'customtab') ?>
</div>
<?php endif; ?>
</div></div></div>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<?php endif;?>
</div>
</div>
<!--PRODUCT BOX EOF-->
</form>
</div>
</div>
</div>
<?php echo $this->getChildHtml('upsell_products') ?>
<script type="text/javascript">
<?php
?>
jQuery(function(){
var PreviewSliderHeight = function() {
var big_image_height= <?php echo $height_thumbs?>;
var preview_image_height= jQuery('div.more-views ul.slides li:first-child').height();
var slider_height = Math.round (big_image_height/preview_image_height) * preview_image_height - 10;
jQuery(".flexslider.more-views .flex-viewport").css({
"min-height": slider_height + "px"
});
if((slider_height-(jQuery('div.more-views ul.slides li:first-child').height()*jQuery('div.more-views ul.slides li').length))>=-10)
{
jQuery('.more-views .flex-next').remove()
jQuery('.more-views .flex-prev').remove()
}
};
jQuery('.flexslider.more-views').flexslider({
animation: "slide",
autoplay: false,
minItems: 3,
animationLoop: false,
direction: "vertical",
controlNav: false,
slideshow: false,
prevText: "<i class='icon-down'></i>",
nextText: "<i class='icon-up'></i>",
start: PreviewSliderHeight
});
})
</script>
<script type="text/javascript">
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
<?php if(Mage::getStoreConfig('buyshopconfig/options/ajax_add_to_cart')){?>
productAddToCartForm.submit = function(button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
// Start of our new ajax code
if (!url) {
url = jQuery('#product_addtocart_form').attr('action');
}
url = url.replace("checkout/cart","ajax/index"); // New Code
var data = jQuery('#product_addtocart_form').serialize();
data += '&isAjax=1';
jQuery('#preloader .loader').fadeIn(300);
try {
jQuery.ajax( {
url : url,
dataType : 'json',
type : 'post',
data &colon; data,
success : function(data) {
jQuery('#ajax_loader').hide();
if(data.status == 'ERROR'){
jQuery('#preloader .loader').hide();
jQuery('#preloader .inside').html(data.message);
jQuery('#preloader .message').fadeIn(300);
setTimeout(function(){
jQuery('#preloader .message').fadeOut();
},1500);
}else{
jQuery('#preloader .loader').hide();
if(jQuery('.ul_wrapper.toplinks')){
jQuery('.shoppingcart').replaceWith(data.sidebar);
}
jQuery(".shoppingcart .fadelink").bind({
mouseenter: function(e) {
jQuery(this).find(".shopping_cart_mini").stop(true, true).fadeIn(300, "linear");
},
mouseleave: function(e) {
jQuery(this).find(".shopping_cart_mini").stop(true, true).fadeOut(300, "linear");
}
});
if(jQuery('#topline .links')){
jQuery('#topline .links').replaceWith(data.toplink);
}
jQuery('#preloader .inside').html(data.message);
jQuery('#preloader .message').fadeIn(300);
setTimeout(function(){
jQuery('#preloader .message').fadeOut();
},1500)
}
}
});
} catch (e) {
}
// End of our new ajax code
this.form.action = oldUrl;
if (e) {
throw e;
}
}
}.bind(productAddToCartForm);
<?php }else { ?>
productAddToCartForm.submit = function(button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
<?php } ?>
productAddToCartForm.submitLight = function(button, url){
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
<?php if(!Mage::helper('lightboxes')->isActive()):?>
jQuery("a.video").click(function() {
jQuery.fancybox({
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'width' : 680,
'height' : 495,
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
});
return false;
});
<?php endif;?>
//]]>
When you have products with multiple options the details box ends up way beneath them so that the customer many not even see them. So, just in case anyone else has this issue & wants/needs assistance doing this. In order to move the "Details/Description" box above the add to cart button & keep the add to cart button functioning......
1. Details/Description Box - move the following code to above the last two </div> right before <!--PRODUCT BOX EOF-->:
<?php $modules_enable=Mage::getStoreConfig('advanced/modules_disable_output');?>
<div class="row">
<div class="span12">
<ul class="nav-tabs" id="myTab">
<li class="active"><?php echo $this->__('Description') ?></li>
<?php if(!$modules_enable['Mage_Review']):?><li><?php echo $this->__('Reviews') ?></li><?php endif;?>
<?php if(!$modules_enable['Mage_Tag']):?><li><?php echo $this->__('Tags') ?></li><?php endif;?>
<?php if ($_customtab && Mage::getStoreConfig('buyshoplayout/product_info/custom_tab')): ?>
<li><?php if(!empty($_cu`enter code here`stomtabtitle)) echo html_entity_decode($this->helper('catalog/output')->productAttribute($this->getProduct(), $_customtabtitle, 'customtabtitle'));else echo 'Custom tab title' ?></li>
<?php endif;?>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
<div class="box-collateral <?php echo "box-{$alias}"?>">
<?php if ($title = $this->getChildData($alias, 'title')):?>
<h2><?php echo $this->escapeHtml($title); ?></h2>
<?php endif;?>
<?php echo $html; ?>
</div>
<?php endforeach;?>
</div>
<div class="tab-pane" id="tab2">
<?php echo $this->getChildHtml('reviews') ?>
</div>
<div class="tab-pane" id="tab3">
<?php echo $this->getChildHtml('product_additional_data') ?>
</div>
<?php if ($_customtab): ?>
<div class="tab-pane" id="tab4">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_customtab, 'customtab') ?>
</div>
<?php endif; ?>
2. Add to cart button - move the following code beneath <!--PRODUCT BOX EOF--> (Each piece of code is located in a separate part of the product box so just look for them & put them together)
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
And
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<?php endif;?>
And
</form>