Skip to content

Commit

Permalink
Moved directory structure to make it compatible for Packagist repository
Browse files Browse the repository at this point in the history
  • Loading branch information
askwhyweb committed Oct 4, 2019
1 parent 5c34d76 commit 0974e68
Show file tree
Hide file tree
Showing 76 changed files with 3,428 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Api/DiscountpercouponManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace OrviSoft\CouponPerProduct\Api;

interface DiscountpercouponManagementInterface
{

/**
* GET for Discountpercoupon api
* @param string $param
* @return string
*/
public function getDiscountpercoupon($param);
}
87 changes: 87 additions & 0 deletions Block/Adminhtml/Coupons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

namespace OrviSoft\CouponPerProduct\Block\Adminhtml;

class Coupons extends \Magento\Backend\Block\Widget\Container
{
/**
* @var string
*/
protected $_template = 'coupons/coupons.phtml';

/**
* @param \Magento\Backend\Block\Widget\Context $context
* @param array $data
*/
public function __construct(\Magento\Backend\Block\Widget\Context $context,array $data = [])
{
parent::__construct($context, $data);
}

/**
* Prepare button and grid
*
* @return \Magento\Catalog\Block\Adminhtml\Product
*/
protected function _prepareLayout()
{


$addButtonProps = [
'id' => 'add_new',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'Magento\Backend\Block\Widget\Button\SplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);


$this->setChild(
'grid',
$this->getLayout()->createBlock('OrviSoft\CouponPerProduct\Block\Adminhtml\Coupons\Grid', 'orvisoft.coupons.grid')
);
return parent::_prepareLayout();
}

/**
*
*
* @return array
*/
protected function _getAddButtonOptions()
{

$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];

return $splitButtonOptions;
}

/**
*
*
* @param string $type
* @return string
*/
protected function _getCreateUrl()
{
return $this->getUrl(
'couponperproduct/*/new'
);
}

/**
* Render grid
*
* @return string
*/
public function getGridHtml()
{
return $this->getChildHtml('grid');
}

}
103 changes: 103 additions & 0 deletions Block/Adminhtml/Coupons/Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace OrviSoft\CouponPerProduct\Block\Adminhtml\Coupons;

class Edit extends \Magento\Backend\Block\Widget\Form\Container
{
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry = null;

/**
* @param \Magento\Backend\Block\Widget\Context $context
* @param \Magento\Framework\Registry $registry
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Framework\Registry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}

/**
* Initialize coupons edit block
*
* @return void
*/
protected function _construct()
{
$this->_objectId = 'id';
$this->_blockGroup = 'OrviSoft_CouponPerProduct';
$this->_controller = 'adminhtml_coupons';

parent::_construct();

$this->buttonList->update('save', 'label', __('Save Coupons'));
$this->buttonList->add(
'saveandcontinue',
[
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'],
],
]
],
-100
);

$this->buttonList->update('delete', 'label', __('Delete Coupons'));
}

/**
* Retrieve text for header element depending on loaded post
*
* @return \Magento\Framework\Phrase
*/
public function getHeaderText()
{
if ($this->_coreRegistry->registry('coupons')->getId()) {
return __("Edit Coupons '%1'", $this->escapeHtml($this->_coreRegistry->registry('coupons')->getTitle()));
} else {
return __('New Coupons');
}
}

/**
* Getter of url for "Save and Continue" button
* tab_id will be replaced by desired by JS later
*
* @return string
*/
protected function _getSaveAndContinueUrl()
{
return $this->getUrl('couponperproduct/*/save', ['_current' => true, 'back' => 'edit', 'active_tab' => '{{tab_id}}']);
}

/**
* Prepare layout
*
* @return \Magento\Framework\View\Element\AbstractBlock
*/
protected function _prepareLayout()
{
$this->_formScripts[] = "
function toggleEditor() {
if (tinyMCE.getInstanceById('page_content') == null) {
tinyMCE.execCommand('mceAddControl', false, 'content');
} else {
tinyMCE.execCommand('mceRemoveControl', false, 'content');
}
};
";
return parent::_prepareLayout();
}

}
27 changes: 27 additions & 0 deletions Block/Adminhtml/Coupons/Edit/Form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace OrviSoft\CouponPerProduct\Block\Adminhtml\Coupons\Edit;

/**
* Adminhtml coupons edit form block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Form extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post' , 'enctype' => 'multipart/form-data']]
);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
Loading

0 comments on commit 0974e68

Please sign in to comment.