function PageContent() { ?> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function() { // fix to preserve width of cells var fixHelper = function(e, ui) { ui.children().each(function() { $(this).width($(this).width()); }); return ui; }; var saveIndex = function(e, ui) { //alert("New position: " + ui.item.index()); //alert("Image Id: " + ui.item.attr("id")); id = ui.item.attr("id").replace("img_", ""); $.ajax({ url: 'featuredpartner_list.php', data: { dragsort: 1, idx: ui.item.index(), id: id }, type: 'POST', dataType: 'html', success: function (data) { //alert("done"); }, error: function (xhr, status) { alert('Sorry, there was a problem!'); } }); }; // end saveIndex $("#list_table tbody").sortable({ helper: fixHelper, stop: saveIndex }).disableSelection(); }); // end document.ready </script> <style> .icon-resize-vertical:hover { cursor:grab; } </style> <div class="layout center-flex"> <?php $aLabels = array(); $aLinks = array(); $aLabels[0] = 'Home'; $aLinks[0] = 'mainpage.php'; $aLabels[1] = 'Featured Partner'; $aLinks[1] = ''; echo Helpers::CreateBreadCrumbs($aLabels, $aLinks); ?> <div class="bigbotspace flex-container space-between"> <p class="larger auto heading">Featured Partner</p> <button class=" "><a href="featuredpartner_admin.php" class="button_link">Add New Featured Partner</a></button> </div> </div> <div class="layout"> <table class="tablestyle" id="list_table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>URL</th> <th>Image</th> <th class="mid">Order</th> <th class="mid">Actions</th> </tr> </thead> <tbody> <?php $objFeaturedPartner = new FeaturedPartner(); $oFeaturedPartner = $objFeaturedPartner->GetAllFeaturedPartner('sort_order'); foreach ($oFeaturedPartner as $featuredpartner) { echo '<tr id="img_' . $featuredpartner->Id . '">' . PHP_EOL; echo '<td style="vertical-align: top;">' . $featuredpartner->Id . '</td>' . PHP_EOL; echo '<td style="vertical-align: top;">' . $featuredpartner->PartnerName . '</td>' . PHP_EOL; echo '<td style="vertical-align: top;">' . $featuredpartner->LinkUrl . '</td>' . PHP_EOL; echo '<td>'; if ($featuredpartner->ImageFile != '') { echo '<img src="/' . $objFeaturedPartner->GetPath() . $featuredpartner->ImageFile . '" width="100" />'; } else { echo ' '; } echo '</td>' . PHP_EOL; echo '<td class="mid" style="vertical-align: top;"><img src="img/arrow-up-down.png" /></td>' . PHP_EOL; echo '<td class="mid" style="vertical-align: top;"><a href="featuredpartner_admin.php?id=' . $featuredpartner->Id . '"><img src="img/edit-icon.png" /></a> <a href="featuredpartner_delete.php?id=' . $featuredpartner->Id . '"><img src="img/delete-icon.png" /></a></td>' . PHP_EOL; echo '</tr>' . PHP_EOL; } ?> </tbody> </table> </div> <!-- layout --> <?php }
exit; } if ($_POST['commit'] == "Save Featured Partner") { if ($id == 0) { // add the listing $objFeaturedPartner = new FeaturedPartner(); $objFeaturedPartner->PartnerName = $_REQUEST["partner_name"]; $objFeaturedPartner->LinkUrl = $_REQUEST["link_url"]; $objFeaturedPartner->Create(); $objFeaturedPartner->HandleFileUploads(); $objFeaturedPartner->HandleDropFileUploads($aDropFields[0], 'ImageFile'); // redirect to listing list header("Location:featuredpartner_list.php"); exit; } else { $objFeaturedPartner = new FeaturedPartner($_REQUEST["id"]); $objFeaturedPartner->PartnerName = $_REQUEST["partner_name"]; $objFeaturedPartner->LinkUrl = $_REQUEST["link_url"]; $objFeaturedPartner->Update(); $objFeaturedPartner->HandleFileUploads(); $objFeaturedPartner->HandleDropFileUploads($aDropFields[0], 'ImageFile'); // redirect to listing list header("Location:featuredpartner_list.php"); exit; } } else { if ($_REQUEST['mode'] == 'e') { //listing $objFeaturedPartner = new FeaturedPartner($id); $partner_name = $objFeaturedPartner->PartnerName; $link_url = $objFeaturedPartner->LinkUrl;
require '../inc/classes/Helpers.php'; // page vars $page_title = ""; $id = $_REQUEST['id']; // id required if ($id == "") { header("Location:mainpage.php"); exit; } // if form was submitted if ($_POST['commit'] == "Cancel") { header("Location:featuredpartner_list.php"); exit; } if ($_POST['commit'] == "Delete Featured Partner") { $objFeaturedPartner = new FeaturedPartner(); $objFeaturedPartner->Delete($id); header("Location:featuredpartner_list.php"); exit; } $objFeaturedPartner = new FeaturedPartner($id); include "includes/pagetemplate.php"; function PageContent() { global $objFeaturedPartner; global $id; ?> <div class="layout laymidwidth"> <?php