Skip to content

Commit

Permalink
Dev: Clean up (CintLink)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jul 28, 2016
1 parent ed604cd commit 086457c
Showing 1 changed file with 27 additions and 105 deletions.
132 changes: 27 additions & 105 deletions application/core/plugins/CintLink/model/CintLinkOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,24 @@ public function getCompletedCheck()

/**
* Used in grid view
* @todo Use $plugin->gT instead of gT - how??
* @return string
*/
public function getStyledStatus()
{
$plugin = Yii::app()->getPlugin();
switch ($this->status)
{
case 'live':
return '<span class="label label-success">' . gT(ucfirst($this->status)) . '</span>';
return '<span class="label label-success">' . $plugin->gT(ucfirst($this->status)) . '</span>';
break;
case 'denied':
return '<span class="label label-danger">' . gT(ucfirst($this->status)) . '</span>';
return '<span class="label label-danger">' . $plugin->gT(ucfirst($this->status)) . '</span>';
break;
case 'new':
return gT('Under review');
break;
default:
return gT(ucfirst($this->status));
return $plugin->gT(ucfirst($this->status));
break;
}
}
Expand All @@ -136,113 +136,35 @@ public function getStyledStatus()
*/
public function getButtons()
{
/*
<!-- Button column -->
<?php if ($order->status == 'hold'): ?>
<td>
<a
class='btn btn-default btn-sm <?php if ($order->ordered_by != $user->id): echo 'readonly'; endif; ?>'
href='https://www.limesurvey.org/index.php?option=com_nbill&action=orders&task=order&cid=10&ctl_order_id=<?php echo htmlspecialchars($order->url); ?>'
target='_blank'
<?php if ($order->ordered_by != $user->id): ?>
data-toggle='tooltip'
title='<?php echo $plugin->gT('You can only pay for orders you placed your self.'); ?>'
onclick='return false;'
<?php endif; ?>
>
<span class='fa fa-credit-card'></span>
&nbsp;
<?php echo $plugin->gT('Pay now'); ?>
</a>
&nbsp;
<button
data-toggle='modal'
data-target='#confirmation-modal'
data-onclick='(function() { LS.plugin.cintlink.cancelOrder("<?php echo $order->url; ?>"); })'
class='btn btn-warning btn-sm'
>
<span class='fa fa-ban'></span>
&nbsp;
<?php echo $plugin->gT('Cancel'); ?>
</button>
</td>
<?php elseif ($order->status == 'new'): ?>
<td></td>
<?php elseif ($order->status == 'cancelled'): ?>
<td>
<button
data-toggle='modal'
data-target='#confirmation-modal'
data-onclick='(function() { LS.plugin.cintlink.softDeleteOrder("<?php echo $order->url; ?>"); })'
class='btn btn-warning btn-sm'
>
<span class='fa fa-trash'></span>
&nbsp;
<?php echo $plugin->gT('Delete'); ?>
</button>
</td>
<?php elseif ($order->status == 'live'): ?>
<td></td>
<?php elseif ($order->status == 'denied'): ?>
<td></td>
<?php elseif ($order->status == 'completed'): ?>
<td></td>
<?php endif; ?>
*/
$plugin = Yii::app()->getPlugin();
switch ($this->status)
{
case 'hold':
$orderedByMe = $this->ordered_by == $this->user->uid;
$readonly = $orderedByMe ? 'readonly' : '';
return $plugin->renderPartial('buttons.hold', array(), true);

//Yii::app()->getPlugin()->renderPartial(); // Possible if we modify LSYii_Application
//Yii::app()->getController()->renderPartial(); // <--- PluginController
//CintLinkController->renderPartial();
/*
return "
<a
class='btn btn-default btn-sm " . $readonly . "'
href='https://www.limesurvey.org/index.php?option=com_nbill&action=orders&task=order&cid=10&ctl_order_id=" . htmlspecialchars($this->url) . "'
target='_blank'
<?php if ($order->ordered_by != $user->id): ?>
data-toggle='tooltip'
title='<?php echo $plugin->gT('You can only pay for orders you placed your self.'); ?>'
onclick='return false;'
<?php endif; ?>
>
<span class='fa fa-credit-card'></span>
&nbsp;
<?php echo $plugin->gT('Pay now'); ?>
</a>
&nbsp;
<button
data-toggle='modal'
data-target='#confirmation-modal'
data-onclick='(function() { LS.plugin.cintlink.cancelOrder("<?php echo $order->url; ?>"); })'
class='btn btn-warning btn-sm'
>
<span class='fa fa-ban'></span>
&nbsp;
<?php echo $plugin->gT('Cancel'); ?>
</button>
";
*/

$data = array();
$data['order'] = $this;
$data['user'] = Yii::app()->user;

$orderedByMe = $this->ordered_by == $data['user']->id;
$data['readonly'] = $orderedByMe ? '' : 'readonly';

return $plugin->renderPartial('buttons.hold', $data, true);

break;

case 'cancelled':
return "
<button
data-toggle='modal'
data-target='#confirmation-modal'
data-onclick='(function() { LS.plugin.cintlink.softDeleteOrder(\"" . $this->url . "\"); })'
class='btn btn-warning btn-sm'
>
<span class='fa fa-trash'></span>
&nbsp;
" . gT('Delete') . "
</button>
";

$data = array();
$data['order'] = $this;
return $plugin->renderPartial('buttons.cancelled', $data, true);

break;

case 'new':
case 'live':
case 'denied':
case 'completed':
// Empty td
break;
}

Expand Down

0 comments on commit 086457c

Please sign in to comment.