<?php
$i = 1;
$photo_int_glcode = "";
if (!empty($photosArr)) {
    foreach ($photosArr as $key => $photo) {

        $photo_thumb = $photo['var_image'];
        $thumb = "../upimages/productphotogallery/images/thumb/thumb_" . $photo_thumb;
        if (file_exists($thumb)) {
            $thumbphoto = SITE_PATH . "upimages/productphotogallery/images/thumb/thumb_" . $photo_thumb;
            $mainphoto = SITE_PATH . "upimages/productphotogallery/images/thumb/" . $photo_thumb;
        } else {
            $thumbphoto = 'images/admin-image.jpg';
        }
        $selected = ($photo['var_primary'] == 'Y') ? 'photo-default-icon active' : 'photo-default-icon';
// display
        
        $primary = ($photo['chr_defaultimage'] == 'Y') ? 'photo-default-icon active' : 'photo-default-icon';
        $display = ($photo['chr_publish'] == 'Y') ? 'publish-icon active' : 'publish-icon';
        $display_title = ($photo['chr_publish'] == 'Y') ? 'Hide me' : 'Display me';
        $photo_int_glcode .= $photo['int_displayorder'] . ',';
    ?>
        <li data-itemid="<?php echo $photo['int_displayorder']; ?>" id="<?= $photo['int_glcode'] ?>">
            <div class="photo-wrapper">
                <div class="photo-wrapper-img" >
                    <table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="269" height="161" align="center" valign="middle" id="drg-img-div">
                              <img src="<?php echo $thumbphoto ?>" alt="photos" id="drg-img" style="cursor: pointer;"/></td>
                        </tr>
                    </table>
                </div>
                <div class="photo-caption">
                    <?php
                    if ($photo['varphotocaption'] == '') {
                        $imagename = $photo['albumTitle'];
                    } else {
                        $imagename = $photo['varphotocaption'];
                    }
                    ?>
                    <textarea name="varphotocaption" cols="" rows="" id="varphotocaption_<?= $photo['int_glcode'] ?>" ><?php echo $imagename; ?></textarea>
                </div>
                <div class="photo-icons" >
                    <a href="javascript:void(0);" onclick="setalbumcoverphoto('<?= $photo['int_glcode'] ?>', '<?= $_REQUEST['fk_product'] ?>')" class="<?=$primary?>" title="Primary Photo">Home Cover</a>
                     <?php
                    if($photo['chr_defaultimage'] != 'Y' || $productphotogalleryObj->countphotodelete($_REQUEST['fk_product'])==1)
                    {
                     ?>
                    <a href="javascript:void(0);" onclick="deletealbumphoto('<?= $photo['int_glcode'] ?>','<?= $_REQUEST['fk_product'] ?>','<?= $photo['chr_delete'] ?>')" class="delete-icon" title="Delete Photo"></a>
                     <?php
                    }
                    ?>
                    <a href="javascript:void(0);" onclick="savealbumcaption('<?= $photo['int_glcode'] ?>','<?= $_REQUEST['fk_product'] ?>')" class="save-icon" title="Save Caption"></a>
                     <?php
                    if($photo['chr_defaultimage'] != 'Y')
                    {
                    ?>
                    <a href="javascript:void(0);" onclick="setpublish_unpublish('<?= $photo['int_glcode'] ?>','<?= $_REQUEST['fk_product'] ?>','<?= $photo['chr_publish'] ?>');" class="<?= $display ?>" title="<?= $display_title ?>"></a>
                     <?php
                    }
                    ?>
                    <a onClick="return hs.expand(this);"  title="View Photo" href="<?php echo $mainphoto ?>"><img  src="<?php echo $thumbphoto ?>" alt="View" width="33" style="width:33px;height: 30px" border="0" align="absmiddle" id="myimage" /></a>
                </div>
            </div>       
        </li>
        <?php
        $i++;
    }
} else {
    echo '<div style="text-align: center;padding: 10px;" id="nophoto">No photos uploaded</div>';
}
?>  

