Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Copyright 2013 Zendesk.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got a license fine in the root of the repo (https://github.com/zendesk/magento_extension/blob/master/LICENSE). I'm happy to not have these at the top of each file going forward.

*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class Zendesk_Zendesk_Block_Adminhtml_Config_Buttons_Sync extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _prepareLayout()
{
parent::_prepareLayout();
if (!$this->getTemplate()) {
$this->setTemplate('zendesk/config/button-sync.phtml');
}
return $this;
}

public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$originalData = $element->getOriginalData();
$this->addData(array(
'button_label' => Mage::helper('zendesk')->__($originalData['button_label']),
'html_id' => $element->getHtmlId(),
'url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/zendesk/sync')
));

return $this->_toHtml();
}

public function getTestUrl()
{
return Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/zendesk/sync');
}

public function getAuthHeader()
{
return 'Token token="' . Mage::helper('zendesk')->getApiToken(false) . '"';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright 2015 Zendesk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class Zendesk_Zendesk_Block_Adminhtml_Create_Customer extends Mage_Adminhtml_Block_Widget_Form_Container
{

public function __construct()
{
parent::__construct();
$this->setId('zendesk_create_customer_search');
}

public function getHeaderText()
{
return Mage::helper('zendesk')->__('Please Select User to Add');
}

public function getButtonsHtml()
{
$addButtonData = array(
'label' => Mage::helper('zendesk')->__('Select User'),
'onclick' => 'showUsers()',
'id' => 'show-users'
);
return $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addButtonData)->toHtml();
}

public function getHeaderCssClass()
{
return 'head-catalog-customer';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* Copyright 2015 Zendesk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class Zendesk_Zendesk_Block_Adminhtml_Create_Customer_Grid extends Mage_Adminhtml_Block_Widget_Grid
{

public function __construct()
{
parent::__construct();
$this->setId('zendesk_create_customer_search_grid');
$this->setDefaultSort('entity_id');
$this->setUseAjax(true);
if ($this->getRequest()->getParam('collapse')) {
$this->setIsCollapsed(true);
}
}

/**
* Retrieve quote store object
* @return Mage_Core_Model_Store
*/
public function getStore()
{
return Mage::getSingleton('adminhtml/session_quote')->getStore();
}

/**
* Prepare collection to be displayed in the grid
*
* @return Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid
*/
protected function _prepareCollection()
{
$collection = Mage::getModel('customer/customer')->getCollection()
->addAttributeToSelect('firstname')
->addAttributeToSelect('lastname')
->addAttributeToSelect('email');


$this->setCollection($collection);
return parent::_prepareCollection();
}

/**
* Prepare columns
*
* @return Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid
*/
protected function _prepareColumns()
{
$this->addColumn('entity_id', array(
'header' => Mage::helper('zendesk')->__('ID'),
'sortable' => true,
'width' => '60',
'index' => 'entity_id'
));
$this->addColumn('firstname', array(
'header' => Mage::helper('zendesk')->__('Firstname'),
'index' => 'firstname'
));
$this->addColumn('lastname', array(
'header' => Mage::helper('zendesk')->__('Lastname'),
'index' => 'lastname'
));
$this->addColumn('email', array(
'header' => Mage::helper('zendesk')->__('Email'),
'index' => 'email'
));
$this->addColumn('action', array(
'header' => Mage::helper('zendesk')->__('Action'),
'renderer' => 'zendesk/adminhtml_create_customer_grid_renderer_action',
'filter' => false,
'sortable' => false
));

return parent::_prepareColumns();
}

public function getGridUrl()
{
return $this->getUrl('adminhtml/zendesk/loadBlock', array('block'=>'customer_grid', '_current' => true, 'collapse' => null));
}

public function getRowUrl($row)
{
return "";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright 2015 Zendesk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class Zendesk_Zendesk_Block_Adminhtml_Create_Customer_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
if ($row->getId()) {
return "<button title='".Mage::helper('zendesk')->__('Add')."' type='button' class='scalable' onclick='javascript:insertUser(".$row->getId()."); return false;'><span><span><span>".Mage::helper('zendesk')->__('Add')."</span></span></span></button>";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Zendesk_Zendesk_Block_Adminhtml_Create_Edit extends Mage_Adminhtml_Block_W
{
protected function _construct()
{
parent::_construct();
$this->_controller = FALSE;
parent::_construct();
}

protected function _preparelayout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ protected function _prepareForm()

$fieldset->addField('order', 'text', array(
'name' => 'order',
'label' => Mage::helper('zendesk')->__('Order number'),
'title' => Mage::helper('zendesk')->__('Order number'),
'label' => Mage::helper('zendesk')->__('Order Number'),
'title' => Mage::helper('zendesk')->__('Order Number'),
'required' => false
));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright 2015 Zendesk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class Zendesk_Zendesk_Block_Adminhtml_Create_Order extends Mage_Adminhtml_Block_Widget_Form_Container
{

public function __construct()
{
parent::__construct();
$this->setId('zendesk_create_order_search');
}

public function getHeaderText()
{
return Mage::helper('zendesk')->__('Please Select Order to Add');
}

public function getButtonsHtml()
{
$addButtonData = array(
'label' => Mage::helper('zendesk')->__('Select Order'),
'onclick' => 'showOrders()',
'id' => 'show-orders'
);
return $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addButtonData)->toHtml();
}

public function getHeaderCssClass()
{
return 'head-catalog-order';
}

}
Loading