<?php
$CI = & get_instance();
$CI->load->model('company/company_info_model');
$company = $CI->company_info_model->companyById(element('compID', $this->session->userdata('logged_in')));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />    
        <link rel="shortcut icon" href="<?php echo base_url() ?>img/salihin_logo.png">
            <title><?php if (isset($rptTitle)) echo $rptTitle; ?> || Reporting</title>

            <link  rel="stylesheet" type="text/css"  href="<?php echo base_url() ?>css/bootstrap/bootstrap.min.css" />
            <?php echo put_headers(); ?>
            <style>

                .resizer_kor:hover {
                    background-color: yellow;
                }

                .thPrint tr{
                    height: 41px;
                }
                .table thead th{
                    vertical-align: middle;
                }

                @media print {     .no-print, 	.no-print *, #scrollUp {         display: none !important;     } }
                @media print {
                    .td-print,.td-print*{display:none !important;}
                    .printTbl hr{
                        margin:0 !important;
                    }
                    .thPrint th{
                        /*background:url(<?php echo base_url() ?>img/rptPaymentAdvice.png) !important;*/
                        /*-webkit-print-color-adjust: exact;*/

                    }
                    /*body{overflow:visible !important;}*/
                    @page{ 
                        size: auto;   /* auto is the initial value */ 

                        /* this affects the margin in the printer settings */ 
                        margin: 10px 10px 10px 10px;  
                    } 

                    /*table { page-break-after:always; }
                    p     { page-break-inside:avoid; page-break-after:avoid; }
                    tr    { page-break-inside:avoid; page-break-after:auto; }
                    td    { page-break-inside:avoid; page-break-after:auto }
                    thead { display:inline; }
                    tfoot { display:inline; }*/
                    .compLogo{
                        width: 150px;
                    }

                }

                .table th,.table td{
                    line-height:10px;
                }
                .table1 td{
                    border:1px solid #dddddd; 
                    padding:5px;
                }

            </style>

            <script>

                var selected = null, // Object of the element to be moved
                        x_pos = 0, y_pos = 0, // Stores x & y coordinates of the mouse pointer
                        x_elem = 0, y_elem = 0; // Stores top, left values (edge) of the element

// Will be called when user starts dragging an element
                function _drag_init(elem) {
                    // Store the object of the element which needs to be moved
                    selected = elem;
                    x_elem = x_pos - selected.offsetLeft;
                    y_elem = y_pos - selected.offsetTop;
                }

// Will be called when user dragging an element
                function _move_elem(e) {
                    x_pos = document.all ? window.event.clientX : e.pageX;
                    y_pos = document.all ? window.event.clientY : e.pageY;

                    if (selected !== null) {
                        selected.style.position = 'absolute';
                        selected.style.top = e.clientY + 'px';
                        selected.style.left = e.clientX + 'px';
                    }
                }


// Destroy the object when we are done
                function _destroy() {
                    selected = null;
                }

// Bind the functions...


                document.onmousemove = _move_elem;
                document.onmouseup = _destroy;




                $(document).ready(function() {

                    document.getElementById('compDetail').onmousedown = function() {
                        _drag_init(this);
                        return false;
                    };

                    document.getElementById('compLogo').onmousedown = function() {
                        _drag_init(this);
                        return false;
                    };

                    document.getElementById('rptTitle').onmousedown = function() {
                        _drag_init(this);
                        return false;
                    };

                    document.getElementById('rptHeaderseparator').onmousedown = function() {
                        _drag_init(this);
                        return false;
                    };
                });

                function do_print() {
                    window.print();
                }


                function _addElement(me) {
                    selected = me;
                }

                //             function getExcelFile() {
                var url = '<?php
            echo base_url();
            echo isset($myUrl) ? $myUrl : '';
            echo '/';
            echo isset($id) ? $id : '';
            ?>"';
                //var url = "<?php echo base_url() ?>ApTransactionReport/printPaymentAdviceRptExel/<?php echo isset($id) ? $id : ''; ?>";
                //                         window.location.href = url;
                //                     }
                function downloadExcel() {
                    var url = "<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '/' . true; ?>";
                    window.location.href = url;
                }
            </script>

    </head>

    <body>


        <table  style="width:97%; margin-top:20px; margin:auto;" class="printTbl">
            <tbody>
                <tr>
                    <td class="resizer_kor" colspan="2" >
                        <div style=" min-height: 150px; width:100%; resize: vertical; overflow: auto;">

                            <img id="compLogo" class="compLogo" src="<?php echo base_url() . 'images/' . element('logo', $this->session->userdata('logged_in')); ?>" style="max-width:150px; max-height:150px; position:absolute; left:20px;top:20px;" />

                            <p id="rptTitle" style="text-align: right; margin:0; padding-right: 10px; font-weight: 500; line-height: 2; padding-bottom: 0px; padding-top: 0px; color: black; font-size: 25px;">
                                <?php if (isset($rptTitle)) echo $rptTitle; ?>
                            </p>
                            <div ondblclick="_addElement(this)" id="compDetail">

                                <?php
                                if (isset($company)) {
                                    foreach ($company as $rowC) {
                                        ?>
                                        <p style="text-align:center; font-size:16px;"> 
                                            <span style=" font-weight:800;"><?php echo $rowC->companyName; ?></span> <span style="font-size:10px;"><?php echo "(" . $rowC->companyNo . ")"; ?></span><br />
                                            <span style="font-size:10px;"><?php echo "GST Registration No : " . $rowC->gstRegisteredNo; ?></span><br />
                                        </p>
                                        <p style="text-align:center; font-size:10px; line-height:1.4; padding:0 0 5px; margin:0;">

                                            <?php if (!empty($rowC->line1)): ?><span><?php echo $rowC->line1; ?></span><br /><?php endif; ?>
                                            <?php if (!empty($rowC->line2) || !empty($rowC->line3)): ?><span><?php echo $rowC->line2 . ", " . $rowC->line3; ?></span><br /><?php endif; ?>
                                            <?php if (!empty($rowC->companyPostCode) || !empty($rowC->city)): ?><span><?php echo $rowC->companyPostCode . '  ' . $rowC->city; ?> </span><br /><?php endif; ?>
                                            <?php if (!empty($rowC->fldname) || !empty($rowC->fldcountry)): ?><span><?php echo $rowC->fldname . '  ' . $rowC->fldcountry; ?> </span><br /><?php endif; ?>
                                            <?php if (!empty($rowC->phoneNo) || !empty($rowC->faxNo)): ?><span><?php echo 'Phone : ' . $rowC->phoneNo . '  Fax : ' . $rowC->faxNo; ?> </span><?php endif; ?>
                                        </p>
                                    </div>
                                    <div id="rptHeaderseparator" style="width: 100%; border-bottom:1px solid #eeeeee;"></div>
                                    <?php
                                }
                            }
                            ?>
                        </div>
                    </td>
                </tr>
                <?php if (isset($leftContentHeader) || isset($leftContent) || isset($rightContentHeader) || isset($rightContent)): ?>
                    <tr>
                        <td>
                            <?php
                            if (isset($leftContentHeader)) {
                                echo "<p style='padding-left:10px; margin:0; font-size:11px; '>"
                                . "<strong>" . $leftContentHeader . "</strong></p>";
                            }

                            if (isset($leftContent)) {
                                echo '<p style="padding-left:10px; margin:0; line-height:1.4;">';
                                foreach ($leftContent as $value) {
                                    echo $value != '' ? "<span>" . $value . "</span><br />" : '';
                                }
                                echo '</p>';
                            }
                            ?>
                        </td>

                        <td valign="top">
                            <?php if (isset($rightContentHeader) || isset($rightContent)): ?>
                                <div style="line-height:1.4; text-align:left; float:right">
                                    <?php
                                    if (isset($rightContentHeader)) {
                                        echo "<p style='padding-right:10px; margin:0; font-size:11px; '>"
                                        . "<strong>" . $rightContentHeader . "</strong></p>";
                                    }
                                    if (isset($rightContent)) {
                                        foreach ($rightContent as $value) {
                                            echo $value != '' ? "<span>" . $value . "</span><br />" : '';
                                        }
                                    }
                                    ?>
                                </div>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endif; ?>

