add webcam to customer create/update

This commit is contained in:
2015-12-30 12:02:26 +01:00
parent 135d64e4c8
commit eb989d5f80
16 changed files with 240 additions and 7 deletions

View File

@@ -0,0 +1,29 @@
<?php
use frontend\assets\CustomerAsset;
use backend\models\CustomerCreate;
CustomerAsset::register($this);
$options = [];
if ( $model instanceof frontend\models\CustomerCreate){
$options['image_data' ] = 'customercreate-photo_data';
}else{
}
$this->registerJs ( 'new Customer( '. json_encode($options).');' );
?>
<style>
.photo{
border: 1px solid gray;
}
</style>
<div class="row">
<div class="col-md-4">
<div id="my_camera" class='photo pull-left' style="width: 160px; height: 120px; margin-right: 12px;"></div>
<div id="my_result" class='photo pull-left' style="width: 160px; height: 120px;"></div>
</div>
<div class="col-md-4">
</div>
</div>
<a id="snap" class="btn btn-primary">Fénykép</a>

View File

@@ -16,7 +16,7 @@ use kartik\widgets\DatePicker;
<div class="customer-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'photo_data')->hiddenInput()->label(false) ?>
<div class='row'>
<div class='col-md-3'>

View File

@@ -18,7 +18,7 @@ use yii\base\Widget;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'photo_data')->hiddenInput()->label(false) ?>
<div class='row'>
<div class='col-md-3'>
<?php //echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>

View File

@@ -20,7 +20,7 @@ $card = $customer->card;
<div class="customer-create">
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/create'] ] )?>
<?php echo $this->render('_camera',['model' => $model]); ?>
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_create', [

View File

@@ -4,10 +4,16 @@ use yii\helpers\Html;
use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionWidget;
use common\assets\WebcamjsAsset;
use frontend\assets\CustomerAsset;
use common\components\Image;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = Yii::t('common/customer', 'Update customer:' ) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_customer]];
@@ -16,6 +22,8 @@ $this->params['breadcrumbs'][] = Yii::t('common/customer', 'Update');
$customer = $model;
$card = $customer->card;
?>
<div class="customer-update">
@@ -23,9 +31,18 @@ $card = $customer->card;
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<?php echo $this->render('_camera',['model' => $model]); ?>
<h1><?= Html::encode($this->title) ?></h1>
<?php if ( $model->image1 ){
echo Html::img( Url::base( ) . Image::thumb( $model->image1->path,160,120 ));
}
?>
<?= $this->render('_form_update', [
'model' => $model,
]) ?>
</div>