Skip to content

Commit

Permalink
added custom sql config example files
Browse files Browse the repository at this point in the history
isbn to isbn13 converter
JBinggi committed Jan 28, 2020
1 parent e94bf7c commit ef9557c
Showing 6 changed files with 102 additions and 91 deletions.
21 changes: 0 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,24 +2,3 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 1.0.0 - TBD

### Added

- Its a composer package now

### Changed

- 100% of 0.9.x Codebase

### Deprecated

- 100% of 0.9.x Codebase

### Removed

- 100% of 0.9.x Codebase

### Fixed

- Removed dependencies
42 changes: 42 additions & 0 deletions data/data_example.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--
-- Core Form - Book Base Fields
--
INSERT INTO `core_form_field` (`Field_ID`, `type`, `label`, `fieldkey`, `tab`, `form`, `class`, `url_view`, `url_ist`, `show_widget_left`, `allow_clear`, `readonly`, `tbl_cached_name`, `tbl_class`, `tbl_permission`) VALUES
(NULL, 'featuredimage', 'Featured Image', 'featured_image', 'book-base', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', ''),
(NULL, 'text', 'Subtitle', 'sub_title', 'book-base', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', ''),
(NULL, 'textarea', 'Description', 'description', 'book-base', 'book-single', 'col-md-8', '', '', '0', '1', '0', '', '', ''),
(NULL, 'select', 'Author', 'author_idfs', 'book-base', 'book-single', 'col-md-3', '', '/tag/api/list/booksingle_3', 0, 1, 0, 'entitytag-single', 'OnePlace\\Tag\\Model\\EntityTagTable', 'add-OnePlace\\Tag\\Controller\\TagController'),
(NULL, 'select', 'Category', 'category_idfs', 'book-base', 'book-single', 'col-md-3', '', '/tag/api/list/booksingle_1', 0, 1, 0, 'entitytag-single', 'OnePlace\\Tag\\Model\\EntityTagTable', 'add-OnePlace\\Tag\\Controller\\TagController'),
(NULL, 'text', 'ISBN', 'isbn', 'book-base', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', ''),
(NULL, 'text', 'ISBN13', 'isbn13', 'book-base', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', '');

--
-- Core Form - Book Details Fields
--
INSERT INTO `core_form_field` (`Field_ID`, `type`, `label`, `fieldkey`, `tab`, `form`, `class`, `url_view`, `url_ist`, `show_widget_left`, `allow_clear`, `readonly`, `tbl_cached_name`, `tbl_class`, `tbl_permission`) VALUES
(NULL, 'select', 'Format', 'format_idfs', 'book-details', 'book-single', 'col-md-3', '', '/tag/api/list/booksingle_5', 0, 1, 0, 'entitytag-single', 'OnePlace\\Tag\\Model\\EntityTagTable', 'add-OnePlace\\Tag\\Controller\\TagController'),
(NULL, 'select', 'Language', 'language_idfs', 'book-details', 'book-single', 'col-md-3', '', '/tag/api/list/booksingle_6', 0, 1, 0, 'entitytag-single', 'OnePlace\\Tag\\Model\\EntityTagTable', 'add-OnePlace\\Tag\\Controller\\TagController'),
(NULL, 'select', 'Publisher', 'publisher_idfs', 'book-details', 'book-single', 'col-md-3', '', '/tag/api/list/booksingle_4', 0, 1, 0, 'entitytag-single', 'OnePlace\\Tag\\Model\\EntityTagTable', 'add-OnePlace\\Tag\\Controller\\TagController'),
(NULL, 'date', 'Publish Date', 'date_publish', 'book-details', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', ''),
(NULL, 'text', 'Pages', 'pages', 'book-details', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', ''),
(NULL, 'text', 'Weight', 'weight', 'book-details', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', ''),
(NULL, 'text', 'Dimensions', 'dimensions', 'book-details', 'book-single', 'col-md-3', '', '', '0', '1', '0', '', '', '');


--
-- book Form Tabs
--
INSERT INTO `core_form_tab` (`Tab_ID`, `form`, `title`, `subtitle`, `icon`, `counter`, `sort_id`, `filter_check`, `filter_value`) VALUES
('book-details', 'book-single', 'Details', 'Infos', 'fas fa-info', '', '1', '', '');

--
-- Tags
--
INSERT INTO `core_tag` (`Tag_ID`, `tag_key`, `tag_label`) VALUES
(3, 'author', 'Author'),
(4, 'publisher', 'Publisher'),
(5, 'format', 'Format'),
(6, 'language', 'Language');



19 changes: 19 additions & 0 deletions data/structure_example.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--
-- Alter book tables
--

ALTER TABLE `book` ADD `sub_title` TEXT NOT NULL DEFAULT '' AFTER `label`;
ALTER TABLE `book` ADD `description` TEXT NOT NULL DEFAULT '' AFTER `sub_title`;
ALTER TABLE `book` ADD `author_idfs` INT(11) NOT NULL DEFAULT '0' AFTER `description`;
ALTER TABLE `book` ADD `isbn` TEXT NOT NULL DEFAULT '' AFTER `author_idfs`;
ALTER TABLE `book` ADD `isbn13` TEXT NOT NULL DEFAULT '' AFTER `isbn`;
ALTER TABLE `book` ADD `publisher_idfs` INT(11) NOT NULL DEFAULT '0' AFTER `isbn13`;
ALTER TABLE `book` ADD `date_publish` TEXT NOT NULL DEFAULT '0000-00-00' AFTER `publisher_idfs`;
ALTER TABLE `book` ADD `category_idfs` INT(11) NOT NULL DEFAULT '0' AFTER `date_publish`;
ALTER TABLE `book` ADD `format_idfs` INT(11) NOT NULL DEFAULT '0' AFTER `category_idfs`;
ALTER TABLE `book` ADD `language_idfs` INT(11) NOT NULL DEFAULT '0' AFTER `format_idfs`;
ALTER TABLE `book` ADD `pages` TEXT NOT NULL DEFAULT '' AFTER `language_idfs`;
ALTER TABLE `book` ADD `weight` TEXT NOT NULL DEFAULT '' AFTER `pages`;
ALTER TABLE `book` ADD `dimensions` TEXT NOT NULL DEFAULT '' AFTER `weight`;
ALTER TABLE `book` ADD `featured_image` VARCHAR(255) NOT NULL DEFAULT '' AFTER `dimensions`;

4 changes: 2 additions & 2 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -28,9 +28,9 @@ class Module {
/**
* Module Version
*
* @since 1.0.6
* @since 1.0.0
*/
const VERSION = '1.0.6';
const VERSION = '1.0.1';

/**
* Load module config file
67 changes: 0 additions & 67 deletions view/layout/book-default.phtml

This file was deleted.

40 changes: 39 additions & 1 deletion view/one-place/book/book/edit.phtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
<h2>Edit Book</h2>

<?= $this->partial('partial/basicform', ['sFormName'=>$sFormName,'oItem'=>$oBook]); ?>
<?= $this->partial('partial/basicform', ['sFormName'=>$sFormName,'oItem'=>$oBook]); ?>

<?php
/**
* @addedtoskeleton
* @requires 1.0.0
* @campatibleto master-dev
*/
?>
<script>
$(function() {
// listen on isbn blur
$('input[name="<?=$sFormName?>_isbn"]').on('blur',function() {
var sISBN = $(this).val();

// check if value is in isbn10 format
if (sISBN.length == 10 && $.isNumeric(sISBN))
{
var iChecksum = 0;

// isbn10 to isbn13 algorithm
var sISBN13 = "978" + sISBN.substring(0, 9);
for (i = 0; i < sISBN13.length; i++) {
iChecksum += (i%2)?parseInt(sISBN13[i]*3):parseInt(sISBN13[i]);
}
iChecksum = (10 - (iChecksum%10)) %10;
sISBN13 = sISBN13 + String(iChecksum);

// write new isbn13
$('input[name="<?=$sFormName?>_isbn13"]').val(sISBN13);
}
});
});
</script>
<?php
/**
* @addedtoskeletonend
*/
?>

0 comments on commit ef9557c

Please sign in to comment.