<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide-full.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide.css" />
<script type="text/javascript">
    hs.graphicsDir = '<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/graphics/';
    hs.outlineType = 'rounded-white';
    hs.showCredits = false;
    hs.wrapperClassName = 'draggable-header';
    hs.align='center';
    hs.width='700';
    function verify()
    {
        SendGridBindRequest("<?= $packageObj->urlwithpara ?>","gridbody","D","chkgrow");
    }
    function share(id){
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=package&action=sharedata&ajax=Y&eid="+id,
            async: false,
            success: function(result){
                $( "#modelpopup" ).html(result);
            }
        });
        $( "#modelpopup" ).dialog({            
            height:380,
            width:620,
            modal: true,
            buttons:{
                "Cancel": function() {
                    $(this).dialog( "close" );
                },
                "Push": function() {
                    var chked = false;
                    $('input:checkbox[name="fb[]"]:checked,input:checkbox[name="tw[]"]:checked').each(function(k,v){
                        chked = true;
                    });
                    if ($('#var_title').val()=='' || $('#var_short_description').val()=='')
                    {
                        alert('Please Enter required fields');
                        return false;
                    }
                    if(chked){
                        var postdata=$("#frmshareoption").serialize();
                        $.ajax({
                            type: "POST",
                            url:"index.php?module=package&action=sharedata&ajax=Y&eid="+id ,
                            data: postdata,
                            async: false,
                            success: function(result){
                                if(trim(result)==1){
                                    alert("Packages pushed successfully.");
                                }else{
                                    alert("Error.. Please try again.");
                                }
                                $( "#modelpopup" ).dialog( "close" );
                                window.location.reload();
                            }
                        });
                    }else{
                        alert(" Please select atleast one page.");
                        return false;
                    }
                }
            }
        });
    }
</script>
<div id="modelpopup" title="Share on Facebook & Twitter"></div>
<div class="web-booking-main" id="gridbody" style="padding-right:2px;">
    <div class="breadcrumbs"><a href="index.php">&nbsp;Home</a>&nbsp;>&nbsp;<span class="current">Manage Packages</span>  </div>
    <div class="clear"></div>
    <?= $messagebox; ?>
    <?php echo $headerpanel; ?>
    <?php echo $pagingTop; ?>
    <?php echo $notemessagebox; ?>
    <div class="clear"></div>
    <div class="grid-list-subtitle-bg" style="margin-top:10px;margin-right:2px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="1%" align="left" valign="middle" class="grid-td-left">
                    <?php if ($paramMain['Delete'] == 'Y') { ?>
                        <input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')"  />
                    <?php } else { ?>
                        &nbsp;
                    <?php } ?>
                <td width="2%" align="center" valign="middle" class="grid-td-top">&nbsp</td>
                <td width="22%" align="left" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $packageObj->urlwithoutsort ?>&orderby=var_title&sorting=Y','gridbody','ST')">Title <?= $setsortimgvar_title ?></a></td>
                <td width="11%" align="left" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $packageObj->urlwithoutsort ?>&orderby=fk_packagetype&sorting=Y','gridbody','ST')">Type <?= $setsortimgfk_packagetype ?></a></td>
                <td width="10%" align="left" valign="middle" class="grid-td-top">
                    <a href="javascript:;" onclick="SendGridBindRequest('<?= $packageObj->urlwithoutsort ?>&orderby=var_price&sorting=Y','gridbody','ST')">
                        Price <?= $setsortimgvar_price ?> 
                    </a>
                </td>
                
                <td width="8%" align="left" valign="middle" class="grid-td-top">Photo</td>

                
                <td width="10%" align="center" valign="middle" class="grid-td-top">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="75%" nowrap><a href="javascript:;" onclick="SendGridBindRequest('<?= $packageObj->urlwithoutsort ?>&orderby=int_displayorder&sorting=Y','gridbody','ST')">Display Order <?= $setsortimgint_displayorder ?></a></td>
                            <td width="20%">
                                <?php if ($paramMain['Edit'] == 'Y') { ?>
                                    <a href="javascript:;" onclick="javascript:SendGridBindRequest('<?= $packageObj->urlwithoutsort ?>','gridbody','DO');"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>save.png" width="16" height="16" alt="save" title="Click here to save the display order/rank" border="0" /></a>
                                <?php } else { ?>
                                    &nbsp;
                                <?php } ?>
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="10%" align="center" valign="top" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $packageObj->urlwithoutsort ?>&orderby=chr_publish&sorting=Y','gridbody','ST')">Publish<?= $setsortimgchr_publish ?></a></td>
                <td width="10%" align="center" valign="middle" class="grid-td-top">
                    Share                
                </td>
            </tr>
        </table>
    </div>
    <div class="information-white-bg" id="dvpersonalinformation" style="margin-right: 2px;">
        <div class="clear"></div>
        <div class="grid-list-inner-table-text">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <?php

                if ($numofrows > 0) { 
                    $rowcount = 0;
                    while ($row = $configObj->glDbObj->fetch_array($result)) {
//                      $clsname = ($row['chr_read'] == 'N') ? "grid-list-inner-table-text-active" : "grid-list-inner-table-text"; // For read unread class
                        $starimg = ($row['chr_star'] == 'Y') ? "gstar.png" : "gstar-disable.png"; // Displaying the stat and unstart image
                        $tool = ($row['chr_star'] == 'Y') ? "Starred" : "Not starred";
                        $tickimg = ($row['chr_publish'] == 'Y') ? "tick.png" : "tick_cross.png"; // Displaying the stat and unstart image
                        if ($row['chr_publish'] == 'Y') {
                            $title = "Hide me";
                        } else {
                            $title = "Display me";
                        }
                        $title = $row["var_title"];
                        $var_description = $row["var_description"];
                        $startdate = $row["date"];
                        $modifydate = strtotime($row['dt_modifydate']);
                        $image = $row["image"];
                        $filep = $row["var_file"];
                        $shareimg = "1-push.png";
                        ?>
                        <tr id="gtr-<?= $row['int_glcode'] ?>"  style="background-color: transparent;"   onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'" >
                            <td width="4%" align="left" valign="middle" class="grid-td-left">
                                <?php if ($paramMain['Delete'] == 'Y') { ?>
                                    <input name="chkgrow" id="chkgrow" type="checkbox" value="<?php echo $row['int_glcode'] ?>" />
                                <?php } else { ?>
                                    &nbsp;
                                <?php } ?>
                            </td>
                            <?php if ($configObj->glSessionObj->value('admin_id') == '1') { ?>
                                <!--<td width="2%" align="center" valign="middle" class="grid-td-top"><img id="star-<?= $row['int_glcode'] ?>" height="16" width="16" alt="remember me" title="<?php echo $tool; ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $starimg ?>" style="vertical-align:middle;cursor:pointer;"onclick="UpdateStar('<?= DB_PREFIX ?>package','chr_star','<?= $row['int_glcode'] ?>');"></td>-->
                            <?php } else { ?>
                                <!--<td width="2%" align="center" valign="middle" class="grid-td-top"></td>-->
                            <?php } ?>
                            <?php
                            $char = substr($row['var_title'], 0, 40);
                            if (strlen($row['var_title']) > 40) {
                                $char.='...';
                            }
                            $createdate = strtotime($row['dt_createdate']);
                            $modifydate = strtotime($row['dt_modifydate']);
                            ?>
                            <td  width="23%" align="left" valign="middle" class="grid-td-top">
                                <?php if ($paramMain['Edit'] == 'Y') { ?>
                                    <a href="<?php echo $packageObj->urlwithpara; ?>&amp;action=edit&amp;eid=<?php echo $row['int_glcode']; ?>"><span><?php echo $char; ?></span></a>
                                <? } else { ?>
                                    <span></span>
                                <?php } ?>
                            </td> 
                            <td width="12%" align="left" valign="middle" class="grid-td-top"><?= $packageObj->catnews($row['fk_packagetype']) ?></td>
                            <td width="10%" align="left" valign="middle" class="grid-td-top"><?= $row['var_price']; ?></td>

                            
                            <td width="8%" align="left" valign="middle" class="grid-td-top">&nbsp;              
                                <?php
                                $imagename = $row['var_image'];
                                $imagepath = '../upimages/package/images/main/thumb_package_';
                                $size = "(" . $packageObj->thumb_width . " x " . $packageObj->thumb_height . " pixels)";
                                $image = $imagepath . "" . $imagename;
                                if ($imagename != "") {                     //echo $image;
                                    if (file_exists($image)) {
                                        ?>
                                        <a onClick="return hs.expand(this);" href="<?php echo $image; ?>"><img border="0" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/photo-gallery-icon.png" title="<?= $row['var_image']; ?>"></a>
                                    <?php } else { ?>
                                        <a onClick="return hs.expand(this);" href="html/images/na-small.gif"><img src="html/images/na-small.gif"  width="20" height="15" ></a>
                                        <?php
                                    }
                                } else {
                                    echo "N/A";
                                }
                                ?>
                            </td>
                             
                           
                    
                            
                            <td width="13%" align="center" valign="middle"  class="grid-td-top"  >
                                <input name="displayorder<?= $rowcount ?>" type="text" class="order" id="displayorder<?= $rowcount ?>"  onkeypress="return KeycheckOnlyNumeric(event);" maxlength="3" value="<?= $row['int_displayorder']; ?>" size="7%" />
                                <input type="hidden" name="hdndisplayorder<?= $rowcount ?>" id="hdndisplayorder<?= $rowcount ?>" value="<?= $row['int_displayorder'] ?>" />
                                <input type="hidden" name="hdnintglcode<?= $rowcount ?>" id="hdnintglcode<?= $rowcount ?>"  value="<?= $row['int_glcode'] ?>" />
                            </td>
                            <td width="10%" align="center" valign="middle" class="grid-td-top">
                                <?php if ($paramMain['Publish'] == 'Y') { ?>
                                    <a href="javascript:void(0);">
                                        <img id="tick-<?= $row['int_glcode'] ?>" height="16" width="16" title="<?= $title ?>" alt="publish me" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $tickimg ?>" style="vertical-align:middle;cursor:pointer;" onclick="UpdatePublish_modulewise('<?= DB_PREFIX ?>package','chr_publish','<?= $row['int_glcode'] ?>','','package');"></a> 
                                <?php } else { ?>
                                    <img id="tick-<?= $row['int_glcode'] ?>" height="16" width="16" alt="<?= $title ?>"  src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $tickimg ?>" style="vertical-align:middle;" onclick="UpdatePublish('<?= DB_PREFIX ?>package','chr_publish','<?= $row['int_glcode'] ?>','');">
                            <?php } ?>
                            </td>
                            <td id="push_<?=$row['int_glcode']?>" width="10%" align="center" valign="middle" class="grid-td-top">
                                <?php if ($row['chr_publish'] == 'Y') { ?>
                                     <img id="shar-<?= $row['int_glcode'] ?>" height="25" width="77" alt="<?= $title . "share" ?>" title="<?= $title . " is share." ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $shareimg ?>" style="vertical-align:middle;cursor:pointer;<?= $display ?>" onclick="share(<?= $row['int_glcode'] ?>);">
                                <?php } else { echo "N/A";?>
                                <?php } ?>
                           </td>

                        </tr>
                        <?php
                        $rowcount++;
                    }
                } else {
                    ?>
                    <tr style="background-color: transparent;"   onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'">
                        <td height="25" align="center" valign="middle" colspan="7" class="form_titles">Sorry! No records are available.</td>
                    </tr>
                    <?php
                }
                ?>
                <input type="hidden" name="ptrecords" id="ptrecords" value="<?= $rowcount ?>">
            </table>
        </div>
    </div>
    <div class="clear"></div>
    <?php echo $pagingBottom; ?>
            <?php if ($numofrows > 0) { ?>
                <?php if ($paramMain['Delete'] == 'Y') { ?>
            <div class="add-new-user-button"><a href="javascript:" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image47','','<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete-button-hover.jpg',0)"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete-button.jpg" alt="Delete" name="Image47" width="80" height="25" border="0" id="Image47" onclick="return verify();" /></a></div>
    <?php } ?>
<?php } ?>
</div>