$description .= " all charges"; } else { $description .= " the first charge"; } } $editActionUrl = 'onclick="mmjs.edit(\'mm-coupons-dialog\', \'' . $coupon->getId() . '\', 620, 615)"'; $deleteActionUrl = 'onclick="mmjs.remove(\'' . $coupon->getId() . '\')"'; $archiveActionUrl = 'onclick="mmjs.archive(\'' . $coupon->getId() . '\')"'; $unarchiveActionUrl = 'onclick="mmjs.unarchive(\'' . $coupon->getId() . '\')"'; $actions = MM_Utils::getEditIcon("Edit Coupon", '', $editActionUrl); $archiveActions = ""; if (!MM_Coupon::isBeingUsed($coupon->getId())) { $actions .= MM_Utils::getDeleteIcon("Delete Coupon", 'margin-left:5px;', $deleteActionUrl); } else { $actions .= MM_Utils::getDeleteIcon("This coupon is currently being used and cannot be deleted.", 'margin-left:5px;', '', true); if (!$coupon->isArchived()) { $archiveMsg = "Archive this coupon to hide it and disable it from being used."; $archiveActions .= MM_Utils::getArchiveIcon($archiveMsg, 'margin-left:5px;', $archiveActionUrl); } else { if ($coupon->isArchived()) { $archiveMsg = "Unarchive this coupon to enable it to be used."; $archiveActions .= MM_Utils::getArchiveIcon($archiveMsg, 'margin-left:5px;', $unarchiveActionUrl, true); } } } $rows[] = array(array('content' => "<span title='ID [" . $coupon->getId() . "]'>" . $coupon->getCouponName() . "</span>"), array('content' => "<span style='font-family:courier;'>" . strtoupper($coupon->getCouponCode()) . "</span>"), array('content' => $description), array('content' => $quantityDescription), array('content' => $availableDates), array('content' => empty($item->product_restrictions) ? MM_NO_DATA : $item->product_restrictions), array('content' => $actions), array('content' => $archiveActions)); } $headers = array('name' => array('content' => '<a onclick="mmjs.sort(\'c.coupon_name\');" href="#">Name</a>'), 'coupon_code' => array('content' => '<a onclick="mmjs.sort(\'c.coupon_code\');" href="#">Coupon Code</a>'), 'description' => array('content' => 'Description'), 'quantity_used' => array('content' => '<a onclick="mmjs.sort(\'quantity_used\');" href="#"># Used</a>'), 'start_date_end_date' => array('content' => '<a onclick="mmjs.sort(\'c.start_date\');" href="#">Valid Dates</a>'), 'product_restrictions' => array('content' => 'Product Restrictions'), 'actions' => array('content' => 'Actions', "attr" => "style='width:50px;'"), 'archive' => array('content' => 'Archive', "attr" => "style='width:20px;'")); $dataGrid->setHeaders($headers); $dataGrid->setRows($rows); $dgHtml = $dataGrid->generateHtml();