Commit a874d14e9559d886e6ed3c6c0744b238cf0dd567
1 parent
432550e1
stock
Showing
13 changed files
with
589 additions
and
0 deletions
Show diff stats
1 | +# Change Log | |
2 | +All notable changes to this project will be documented in this file. | |
3 | + | |
4 | +## 1.0.0 - 2017-03-21 | |
5 | +### Added | |
6 | +- This CHANGELOG file to hopefully serve as an evolving example of a standardized open source project CHANGELOG. | |
7 | +- Added initial Artbox Order extension. | |
0 | 8 | \ No newline at end of file | ... | ... |
1 | +The Yii framework is free software. It is released under the terms of | |
2 | +the following BSD License. | |
3 | + | |
4 | +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) | |
5 | +All rights reserved. | |
6 | + | |
7 | +Redistribution and use in source and binary forms, with or without | |
8 | +modification, are permitted provided that the following conditions | |
9 | +are met: | |
10 | + | |
11 | + * Redistributions of source code must retain the above copyright | |
12 | + notice, this list of conditions and the following disclaimer. | |
13 | + * Redistributions in binary form must reproduce the above copyright | |
14 | + notice, this list of conditions and the following disclaimer in | |
15 | + the documentation and/or other materials provided with the | |
16 | + distribution. | |
17 | + * Neither the name of Yii Software LLC nor the names of its | |
18 | + contributors may be used to endorse or promote products derived | |
19 | + from this software without specific prior written permission. | |
20 | + | |
21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
24 | +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
25 | +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
27 | +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
28 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
29 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
31 | +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
32 | +POSSIBILITY OF SUCH DAMAGE. | ... | ... |
1 | +<?php | |
2 | +namespace artbox\stock\assets; | |
3 | + | |
4 | +use yii\web\AssetBundle; | |
5 | +/** | |
6 | + * Created by PhpStorm. | |
7 | + * User: stes | |
8 | + * Date: 26.07.17 | |
9 | + * Time: 16:10 | |
10 | + */ | |
11 | +class StockAsset extends AssetBundle | |
12 | +{ | |
13 | + public $sourcePath = '@artbox/stock/web'; | |
14 | + | |
15 | + public $css = []; | |
16 | + | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public $js = [ | |
21 | + 'js/stock.js', | |
22 | + | |
23 | + ]; | |
24 | + | |
25 | + public $depends = [ | |
26 | + 'yii\web\JqueryAsset' | |
27 | + ]; | |
28 | +} | |
0 | 29 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | +return [ | |
3 | + 'Cities' => 'Города', | |
4 | + 'Shops' => 'Магазины/склады', | |
5 | + 'Title' => 'Название', | |
6 | + 'Sort' => 'Сортировка', | |
7 | + 'Status' => 'Статус', | |
8 | + 'Description' => 'Описание', | |
9 | + 'Create City' => 'Добавить город', | |
10 | + 'Alias' => 'Алиас', | |
11 | + 'Update' => 'Обновить', | |
12 | + 'Address' => 'Адрес', | |
13 | + 'Create Shop' => 'Добавить магазин', | |
14 | + 'Mode' => "Расписание работы", | |
15 | + 'Delete' => 'Удалить', | |
16 | + 'Create' => "Добавить", | |
17 | +] | |
18 | +?> | |
0 | 19 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation of table `city`. | |
7 | + */ | |
8 | +class m170721_133313_create_city_table extends Migration | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable('city', [ | |
16 | + 'id' => $this->primaryKey(), | |
17 | + 'sort' => $this->integer(), | |
18 | + 'status' => $this->boolean() | |
19 | + ->defaultValue(true), | |
20 | + ]); | |
21 | + } | |
22 | + | |
23 | + /** | |
24 | + * @inheritdoc | |
25 | + */ | |
26 | + public function down() | |
27 | + { | |
28 | + $this->dropTable('city'); | |
29 | + } | |
30 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m170721_135629_create_table_shops extends Migration | |
6 | +{ | |
7 | + public function safeUp() | |
8 | + { | |
9 | + $this->createTable('shop', [ | |
10 | + 'id' => $this->primaryKey(), | |
11 | + 'mode' => $this->text(), | |
12 | + 'city_id' => $this->integer(), | |
13 | + 'sort' => $this->integer(), | |
14 | + 'status' => $this->boolean() | |
15 | + ->defaultValue(true), | |
16 | + 'coords' => $this->string(), | |
17 | + ]); | |
18 | + | |
19 | + $this->addForeignKey( | |
20 | + 'city_city_id_fkey', | |
21 | + 'shop', | |
22 | + 'city_id', | |
23 | + 'city', | |
24 | + 'id', | |
25 | + 'CASCADE', | |
26 | + 'CASCADE' | |
27 | + ); | |
28 | + } | |
29 | + | |
30 | + public function safeDown() | |
31 | + { | |
32 | + $this->dropForeignKey('city_city_id_fkey', 'shop'); | |
33 | + $this->dropTable('shop'); | |
34 | + } | |
35 | + | |
36 | + | |
37 | + /* | |
38 | + // Use up()/down() to run migration code without a transaction. | |
39 | + public function up() | |
40 | + { | |
41 | + | |
42 | + } | |
43 | + */ | |
44 | + | |
45 | + | |
46 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m170724_123453_city_lang extends Migration | |
6 | +{ | |
7 | + public function safeUp() | |
8 | + { | |
9 | + $this->createTable( | |
10 | + 'city_lang', | |
11 | + [ | |
12 | + 'city_id' => $this->integer(32) | |
13 | + ->notNull(), | |
14 | + 'language_id' => $this->integer(32) | |
15 | + ->notNull(), | |
16 | + 'title' => $this->string(255) | |
17 | + ->notNull(), | |
18 | + 'alias_id' => $this->integer(), | |
19 | + 'description' => $this->text(), | |
20 | + ] | |
21 | + ); | |
22 | + | |
23 | + | |
24 | + $this->createIndex('city_lang_alias_id', 'city_lang', 'alias_id', true); | |
25 | + $this->addPrimaryKey( | |
26 | + 'city_lang_pk', | |
27 | + 'city_lang', | |
28 | + [ | |
29 | + 'city_id', | |
30 | + 'language_id', | |
31 | + ] | |
32 | + ); | |
33 | + | |
34 | + | |
35 | + $this->addForeignKey( | |
36 | + 'city_lang_city_id_to_city_fk', | |
37 | + 'city_lang', | |
38 | + 'city_id', | |
39 | + 'city', | |
40 | + 'id', | |
41 | + 'CASCADE', | |
42 | + 'CASCADE' | |
43 | + ); | |
44 | + | |
45 | + $this->addForeignKey( | |
46 | + 'city_lang_language_id_to_language_fk', | |
47 | + 'city_lang', | |
48 | + 'language_id', | |
49 | + 'language', | |
50 | + 'id', | |
51 | + 'RESTRICT', | |
52 | + 'CASCADE' | |
53 | + ); | |
54 | + | |
55 | + $this->addForeignKey( | |
56 | + 'city_lang_alias_id_to_alias_fk', | |
57 | + 'city_lang', | |
58 | + 'alias_id', | |
59 | + 'alias', | |
60 | + 'id', | |
61 | + 'SET NULL', | |
62 | + 'CASCADE' | |
63 | + ); | |
64 | + } | |
65 | + | |
66 | + public function safeDown() | |
67 | + { | |
68 | + $this->dropForeignKey( | |
69 | + 'city_lang_alias_id_to_alias_fk', | |
70 | + 'city_lang' | |
71 | + ); | |
72 | + $this->dropForeignKey( | |
73 | + 'city_lang_language_id_to_language_fk', | |
74 | + 'city_lang' | |
75 | + ); | |
76 | + $this->dropForeignKey( | |
77 | + 'city_lang_city_id_to_city_fk', | |
78 | + 'city_lang' | |
79 | + ); | |
80 | + $this->dropIndex('city_lang_alias_id', 'city_lang'); | |
81 | + $this->dropTable('city_lang'); | |
82 | + } | |
83 | + | |
84 | + | |
85 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m170724_124809_shop_lang extends Migration | |
6 | +{ | |
7 | + public function safeUp() | |
8 | + { | |
9 | + $this->createTable( | |
10 | + 'shop_lang', | |
11 | + [ | |
12 | + 'shop_id' => $this->integer(32) | |
13 | + ->notNull(), | |
14 | + 'language_id' => $this->integer(32) | |
15 | + ->notNull(), | |
16 | + 'title' => $this->string(255) | |
17 | + ->notNull(), | |
18 | + 'alias_id' => $this->integer(), | |
19 | + 'description' => $this->text(), | |
20 | + ] | |
21 | + ); | |
22 | + | |
23 | + $this->createIndex('shop_lang_alias_id', 'shop_lang', 'alias_id', true); | |
24 | + $this->addPrimaryKey( | |
25 | + 'shop_lang_pk', | |
26 | + 'shop_lang', | |
27 | + [ | |
28 | + 'shop_id', | |
29 | + 'language_id', | |
30 | + ] | |
31 | + ); | |
32 | + | |
33 | + $this->addForeignKey( | |
34 | + 'shop_lang_shop_id_to_shop_fk', | |
35 | + 'shop_lang', | |
36 | + 'shop_id', | |
37 | + 'shop', | |
38 | + 'id', | |
39 | + 'CASCADE', | |
40 | + 'CASCADE' | |
41 | + ); | |
42 | + | |
43 | + $this->addForeignKey( | |
44 | + 'shop_lang_language_id_to_language_fk', | |
45 | + 'shop_lang', | |
46 | + 'language_id', | |
47 | + 'language', | |
48 | + 'id', | |
49 | + 'RESTRICT', | |
50 | + 'CASCADE' | |
51 | + ); | |
52 | + | |
53 | + $this->addForeignKey( | |
54 | + 'shop_lang_alias_id_to_alias_fk', | |
55 | + 'shop_lang', | |
56 | + 'alias_id', | |
57 | + 'alias', | |
58 | + 'id', | |
59 | + 'SET NULL', | |
60 | + 'CASCADE' | |
61 | + ); | |
62 | + } | |
63 | + | |
64 | + public function safeDown() | |
65 | + { | |
66 | + $this->dropForeignKey( | |
67 | + 'shop_lang_alias_id_to_alias_fk', | |
68 | + 'shop_lang' | |
69 | + ); | |
70 | + $this->dropForeignKey( | |
71 | + 'shop_lang_language_id_to_language_fk', | |
72 | + 'shop_lang' | |
73 | + ); | |
74 | + $this->dropForeignKey( | |
75 | + 'shop_lang_city_id_to_shop_fk', | |
76 | + 'shop_lang' | |
77 | + ); | |
78 | + $this->dropIndex('shop_lang_alias_id', 'shop_lang'); | |
79 | + $this->dropTable('shop_lang'); | |
80 | + } | |
81 | + | |
82 | + /* | |
83 | + // Use up()/down() to run migration code without a transaction. | |
84 | + public function up() | |
85 | + { | |
86 | + | |
87 | + } | |
88 | + | |
89 | + public function down() | |
90 | + { | |
91 | + echo "m170724_124809_shop_lang cannot be reverted.\n"; | |
92 | + | |
93 | + return false; | |
94 | + } | |
95 | + */ | |
96 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m170725_131257_add_address_to extends Migration | |
6 | +{ | |
7 | + public function safeUp() | |
8 | + { | |
9 | + $this->addColumn('shop_lang', 'address', $this->string()); | |
10 | + } | |
11 | + | |
12 | + public function safeDown() | |
13 | + { | |
14 | + $this->dropColumn('shop_lang', 'address'); | |
15 | + } | |
16 | + | |
17 | + /* | |
18 | + // Use up()/down() to run migration code without a transaction. | |
19 | + public function up() | |
20 | + { | |
21 | + | |
22 | + } | |
23 | + | |
24 | + public function down() | |
25 | + { | |
26 | + echo "m170725_131257_add_address_to cannot be reverted.\n"; | |
27 | + | |
28 | + return false; | |
29 | + } | |
30 | + */ | |
31 | +} | ... | ... |
1 | +<?php | |
2 | + use artbox\catalog\models\BrandLang; | |
3 | + use artbox\core\helpers\SlugifyDecorator; | |
4 | + use artbox\core\models\Language; | |
5 | + use dosamigos\tinymce\TinyMce; | |
6 | + use yii\web\View; | |
7 | + use yii\widgets\ActiveForm; | |
8 | + | |
9 | + /** | |
10 | + * @var BrandLang $model_lang | |
11 | + * @var Language $language | |
12 | + * @var ActiveForm $form | |
13 | + * @var View $this | |
14 | + */ | |
15 | +?> | |
16 | +<?php | |
17 | + $attributeField = $form->field($model_lang, '[' . $language->id . ']title') | |
18 | + ->textInput([ 'maxlength' => true ]); | |
19 | + echo $attributeField; | |
20 | +?> | |
21 | + | |
22 | +<?= SlugifyDecorator::decorate( | |
23 | + $form->field($model_lang, '[' . $language->id . ']aliasValue'), | |
24 | + [ '/alias/slugify' ], | |
25 | + $attributeField, | |
26 | + false, | |
27 | + $language->id | |
28 | +) | |
29 | + ->textInput([ 'maxlength' => true ]); ?> | |
30 | + | |
31 | +<?php | |
32 | + echo $form->field($model_lang, '[' . $language->id . ']description') | |
33 | + ->widget( | |
34 | + TinyMce::className(), | |
35 | + [ | |
36 | + 'options' => [ 'rows' => 6 ], | |
37 | + 'language' => 'ru', | |
38 | + 'clientOptions' => [ | |
39 | + 'file_browser_callback' => new yii\web\JsExpression( | |
40 | + "function(field_name, url, type, win) { | |
41 | +window.open('" . yii\helpers\Url::to( | |
42 | + [ | |
43 | + 'imagemanager/manager', | |
44 | + 'view-mode' => 'iframe', | |
45 | + 'select-type' => 'tinymce', | |
46 | + ] | |
47 | + ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no'); | |
48 | +}" | |
49 | + ), | |
50 | + 'plugins' => [ | |
51 | + "advlist autolink lists link charmap print preview anchor", | |
52 | + "searchreplace visualblocks code fullscreen", | |
53 | + "insertdatetime media table contextmenu paste image", | |
54 | + ], | |
55 | + 'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code", | |
56 | + ], | |
57 | + ] | |
58 | + ); | |
59 | +?> | |
0 | 60 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + use artbox\catalog\models\BrandLang; | |
3 | + use artbox\core\helpers\SlugifyDecorator; | |
4 | + use artbox\core\models\Language; | |
5 | + use dosamigos\tinymce\TinyMce; | |
6 | + use yii\web\View; | |
7 | + use yii\widgets\ActiveForm; | |
8 | +use yii\helpers\Html; | |
9 | + /** | |
10 | + * @var BrandLang $model_lang | |
11 | + * @var Language $language | |
12 | + * @var ActiveForm $form | |
13 | + * @var View $this | |
14 | + */ | |
15 | + //print_r($model_lang->shop->coordsArr); die(); | |
16 | +?> | |
17 | +<?php | |
18 | + $attributeField = $form->field($model_lang, '[' . $language->id . ']title') | |
19 | + ->textInput([ 'maxlength' => true ]); | |
20 | + echo $attributeField; | |
21 | +?> | |
22 | + | |
23 | +<?php | |
24 | +$attributeField = $form->field($model_lang, '[' . $language->id . ']address') | |
25 | + ->textInput([ 'maxlength' => true ]); | |
26 | +echo $attributeField; | |
27 | +?> | |
28 | +<?= Html::label('Координаты');?> | |
29 | +<?= Html::textInput("Shop[coordsArr][lat]", (isset($model_lang->shop->coordsArr['lat'])) ? $model_lang->shop->coordsArr['lat'] : '', [ | |
30 | + 'size' => 20, | |
31 | + 'type'=> 'text', | |
32 | + 'id' => 'lat', | |
33 | + | |
34 | +])?> | |
35 | +<?= Html::textInput("Shop[coordsArr][lng]", (isset($model_lang->shop->coordsArr['lng'])) ? $model_lang->shop->coordsArr['lng'] : '', [ | |
36 | + 'size' => 20, | |
37 | + 'type'=> 'text', | |
38 | + 'id' => 'lng' | |
39 | +])?> | |
40 | + <div id="map_canvas" style="height: 300px;"></div> | |
41 | + | |
42 | +<?= SlugifyDecorator::decorate( | |
43 | + $form->field($model_lang, '[' . $language->id . ']aliasValue'), | |
44 | + [ '/alias/slugify' ], | |
45 | + $attributeField, | |
46 | + false, | |
47 | + $language->id | |
48 | +) | |
49 | + ->textInput([ 'maxlength' => true ]); ?> | |
50 | + | |
51 | +<?php | |
52 | + echo $form->field($model_lang, '[' . $language->id . ']description') | |
53 | + ->widget( | |
54 | + TinyMce::className(), | |
55 | + [ | |
56 | + 'options' => [ 'rows' => 6 ], | |
57 | + 'language' => 'ru', | |
58 | + 'clientOptions' => [ | |
59 | + 'file_browser_callback' => new yii\web\JsExpression( | |
60 | + "function(field_name, url, type, win) { | |
61 | +window.open('" . yii\helpers\Url::to( | |
62 | + [ | |
63 | + 'imagemanager/manager', | |
64 | + 'view-mode' => 'iframe', | |
65 | + 'select-type' => 'tinymce', | |
66 | + ] | |
67 | + ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no'); | |
68 | +}" | |
69 | + ), | |
70 | + 'plugins' => [ | |
71 | + "advlist autolink lists link charmap print preview anchor", | |
72 | + "searchreplace visualblocks code fullscreen", | |
73 | + "insertdatetime media table contextmenu paste image", | |
74 | + ], | |
75 | + 'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code", | |
76 | + ], | |
77 | + ] | |
78 | + ); | |
79 | +?> | |
0 | 80 | \ No newline at end of file | ... | ... |
1 | +$(function() { | |
2 | + | |
3 | + | |
4 | + $(document) | |
5 | + .on("click","#add-data",function () { | |
6 | + var count = $(this).data('count'); | |
7 | + $("<div><label>Дата</label><input type='date' name='Shop[modeStr][data]["+count+"][data]'><label>c</label><input type='time' size='10' name='Shop[modeStr][data]["+count+"][from]'><label>до</label><input type='time' name='Shop[modeStr][data]["+count+"][to]'><label>выходной</label><input type='checkbox' name='Shop[modeStr][data]["+count+"][off]'><a class='delete-day-item'>Удалить</a></div>").insertBefore($(this)) | |
8 | + count+=1; | |
9 | + $(this).data('count', count); | |
10 | + }); | |
11 | + $(document) | |
12 | + .on( | |
13 | + 'click', '.delete-day-item', function() { | |
14 | + var count = $("#add-data").data('count'); | |
15 | + $(this) | |
16 | + .parent() | |
17 | + .remove(); | |
18 | + count-=1; | |
19 | + $("#add-data").data('count', count); | |
20 | + } | |
21 | + ); | |
22 | + $(document).on( '#shoplang-2-address','blur', function () { | |
23 | + var address = $("#shoplang-2-address").val() + " "+$("#select2-w2-container").text(); | |
24 | + console.log(address); | |
25 | + geocoder.geocode( { 'address': address}, function(results, status) { | |
26 | + console.log(status); | |
27 | + if (status == google.maps.GeocoderStatus.OK) { | |
28 | + //console.log(results[0].geometry.location.lat()+" "+results[0].geometry.location.lng()); | |
29 | + $("#lat").val(results[0].geometry.location.lat()); | |
30 | + $("#lng").val(results[0].geometry.location.lng()); | |
31 | + var marker = AddMarker(); | |
32 | + marker.setMap(map); | |
33 | + } else { | |
34 | + alert("Geocode was not successful for the following reason: " + status); | |
35 | + } | |
36 | + }); | |
37 | + }); | |
38 | + | |
39 | + var start_position = new google.maps.LatLng('50.435', '30.60'); | |
40 | + var styles = [ | |
41 | + { | |
42 | + stylers: [ | |
43 | + {saturation: -100} | |
44 | + ] | |
45 | + } | |
46 | + ]; | |
47 | + var settings = { | |
48 | + styles: styles, | |
49 | + zoom: 12, | |
50 | + scrollwheel: false, | |
51 | + center: start_position, | |
52 | + mapTypeControl: true, | |
53 | + mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, | |
54 | + navigationControl: false, | |
55 | + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, | |
56 | + scaleControl: true, | |
57 | + streetViewControl: true, | |
58 | + rotateControl: true, | |
59 | + zoomControl: true, | |
60 | + mapTypeId: google.maps.MapTypeId.ROADMAP | |
61 | + }; | |
62 | + | |
63 | + var map = new google.maps.Map(document.getElementById("map_canvas"), settings); | |
64 | + if ($("#lat").val() !== "" && $("#lng").val() !== ""){ | |
65 | + var marker = AddMarker(); | |
66 | + marker.setMap(map); | |
67 | + } | |
68 | + var geocoder = new google.maps.Geocoder(); | |
69 | + function AddMarker(){ | |
70 | + var newLat = $("#lat").val(); | |
71 | + var newLng = $("#lng").val(); | |
72 | + var coords = new google.maps.LatLng(newLat, newLng); | |
73 | + var marker = new google.maps.Marker({ | |
74 | + position: coords | |
75 | + }); | |
76 | + return marker; | |
77 | + } | |
78 | +}); | ... | ... |