<?php

include('classes/readxml.class.php');

$Get_XML_Responce = new read_xml;

?>

<!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" />

        <title>Equivalenza</title>

        <link href="css/style.css" rel="stylesheet" type="text/css" />

        <link rel='stylesheet' type='text/css' href='css/fullcalendar.css' />

        <!--<link href="css/jquery-ui-calender.css" rel="stylesheet" type="text/css"/>

        <link href="css/thickbox.css" rel="stylesheet" type="text/css"/>-->

        <script type="text/javascript" src="javascripts/jquery.min.js"></script>

        <script type='text/javascript' src='javascripts/fullcalendar.js'></script>

        <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>



        <!--<script type="text/javascript" src="javascripts/jquery.min.js"></script>

        <script type="text/javascript" src="javascripts/jquery-ui-calender.js"></script>

        <script type="text/javascript" src="javascripts/thickbox.js"></script>-->



        <script type="text/javascript">

            function start() {



                var time = new Date()

                var hours = time.getHours()

                var minutes = time.getMinutes()

                minutes = ((minutes < 10) ? "0" : "") + minutes

                var seconds = time.getSeconds()

                seconds = ((seconds < 10) ? "0" : "") + seconds

                var clock = '';

                if (hours == 12) {

                    clock = hours + ":" + minutes;

                }

                else if (hours > 12) {

                    hours = hours;

                    clock = hours + ":" + minutes;

                }

                else {

                    clock = hours + ":" + minutes;

                }

                document.getElementById("dv").innerHTML = clock;

                timer = setTimeout("start()", 1000)

            }

        </script>



        <script type="text/javascript">

            //var json = "";

            $(document).ready(function() {
					
	   			$('#hours').bind('change', function () {
                    if ( $("#hours").val() != 0 ){
						//$("#allday").attr('disabled','disabled');
                        $("#onleave").attr('disabled','disabled');
                    }
                    else{
                        $("#onleave").removeAttr('disabled');
						//$("#allday").removeAttr('disabled');
                    }
                });

                $('#onleave').bind('change', function () {

                    if ($(this).is(':checked')){

                        $("#hours").attr('disabled','disabled');

						$("#allday").removeAttr('checked','checked');
						$("#hours").val(0);
						
                        $("#allday").attr('disabled','disabled');

                    }

                    else{

                        $("#hours").removeAttr('disabled');

                        $("#allday").removeAttr('disabled');

                    }

                });



                <!--   [{"id":"6","title":"sam123 event 6","start":1357171200,"end":1357171200}]   -->

                $('#calendar').fullCalendar({

	

                    events: './json-events.php',

                    eventClick: function(calEvent, jsEvent, view) {

                        $("#update_record_id").val(calEvent.id);

                        $.ajax({

                            type: "POST",

                            url: "json-events.php",

                            data: { UpdateRecord: $("#update_record_id").val() }

                        }).done(function( msg ) {

                            var data = eval(msg)[0];

                            //alert(data.id);

                            $("#header_title").html('Update Hours');

							//var dateform=$.datepicker.formatDate('dd-mm-yy', new Date(data.date));

                            $("#date").html(data.date);

                            $("#hours").val(data.hours);

                            //alert(data.allday );

                            if(data.allday == 1)

                            {

                                $("#allday").attr('checked','checked');

                            }else{

                                $("#allday").removeAttr('checked');

                            }

                            if(data.onleave == 1)

                            {

                                $("#hours").attr('disabled','disabled');

                                $("#allday").attr('disabled','disabled');

                                $("#onleave").attr('checked','checked');

                            }else{

                                $("#hours").removeAttr('disabled');

                                $("#allday").removeAttr('disabled');

                                $("#onleave").removeAttr('checked');

                            }

                            //$("#hours");

                        });

						$("#deletebtn").css("display", "block");

                        //alert('Event: ' + calEvent.title);

                        //alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);

                        //a//lert('View: ' + view.name);

                        /* Update the Record Again Certain ID */

                        $.ajax({

                            type: "POST",

                            url: "day_manage.php",

                            data: { Cal_Event: calEvent.id }

                        }).done(function( msg ) {

                            //alert( msg );

                        });

				

                        $('#test').fadeIn('slow', function() {

                            // Animation complete

                        });

                        //document.getElementById("test").style.display='';

			

                        // change the border color just for fun

                        // $(this).css('color', 'red');



                    },

                    dayClick: function(date, allDay, jsEvent, view) {

                        //alert($("#hours").val());
						if ( $("#hours").val() != 0 ){
                        	//$("#allday").attr('disabled','disabled');
                        	$("#onleave").attr('disabled','disabled');
                    }
                    else{
						//$("#allday").removeAttr('disabled');
                        $("#onleave").removeAttr('disabled');
                    }

						$("#deletebtn").css("display", "none");

                        /* Duplication Check for Events */

		

                        $.ajax({

                            type: "POST",

                            url: "json-events.php",

                            data: { DateCheckDB: date }

                        }).done(function( msgid ) {

                            //alert( msg );

                            if(msgid > 0)

                            {

								$("#deletebtn").css("display", "block");

                                $("#update_record_id").val(msgid);

                                $.ajax({

                                    type: "POST",

                                    url: "json-events.php",

                                    data: { UpdateRecord: $("#update_record_id").val() }

                                }).done(function( msg ) {

                                    var data = eval(msg)[0];

                                    //alert(data.id);

                                    $("#header_title").html('Houras Extras');

									//alert(Date.parseDate(data.date, "d-m-Y"));

                                    $("#date").html(data.date);

									

									

                                    $("#hours").val(data.hours);

                                    //alert(data.allday );

                                    if(data.allday == 1)

                                    {

                                        $("#allday").attr('checked','checked');

                                    }else{

                                        $("#allday").removeAttr('checked');

                                    }

                                    if(data.onleave == 1)

                                    {

                                        $("#hours").attr('disabled','disabled');

                                        $("#allday").attr('disabled','disabled');

                                        $("#onleave").attr('checked','checked');

                                    }else{

										$("#deletebtn").css("display", "none");

                                        $("#hours").removeAttr('disabled');

                                        $("#allday").removeAttr('disabled');

                                        $("#onleave").removeAttr('checked');

                                    }

                                    //$("#hours");

                                });

                                //alert('Event: ' + calEvent.title);

                                //alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);

                                //a//lert('View: ' + view.name);

                                /* Update the Record Again Certain ID */

                                $.ajax({

                                    type: "POST",

                                    url: "day_manage.php",

                                    data: { Cal_Event: msgid }

                                }).done(function( msg ) {

                                    //alert( msg );

                                });

                                $('#test').fadeIn('slow', function() {

                                    // Animation complete

                                });

                                //document.getElementById("test").style.display='';

                            }else{

                                $("#hours").removeAttr('disabled');

                                $("#allday").removeAttr('disabled');

                                $.ajax({

                                    type: "POST",

                                    url: "json-events.php",

                                    data: { DateGet: date }

                                }).done(function( msg ) {

                                    //alert( msg );

                                    var dateform=$.datepicker.formatDate('dd-mm-yy', new Date(msg));

                                    $("#date").html(dateform);	

                                });

		

                                $("#header_title").html('Add Hours')

                               

                                $("#hours").val("1");

                                $("#allday").attr('checked',false);

                                $("#onleave").attr('checked', false);

	

                                if (allDay) {

                                    $("#date").html();

                                    $.ajax({

                                        type: "POST",

                                        url: "day_manage.php",

                                        data: { c_date: date }

                                    }).done(function( msg ) {

                                        //alert( msg );

                                    });

									

									//var currentdate=msg;

									var dateform=$.datepicker.formatDate('dd-mm-yy', new Date(date));
									//dateform = strtotime()

									var currdate =new Date();

									var currdate=$.datepicker.formatDate('dd-mm-yy', new Date(currdate))

									//alert(currdate+"  "+ dateform);

									if(dateform<=currdate){

                                    $('#test').fadeIn('slow');

									}else{
										$('#test').fadeOut('slow');
									}

                                    //drocument.getElementById("test").style.display = '';

                                }else{

                                    //   alert('Clicked on the slot: ' + date);

                                }

                            }

                        });

		

                    }

                });

            });

        </script>

    </head>



    <body onload="start();">



        <div id="siteHeader">

            <?php $_SESSION['C_DATE'];

            $_SESSION['U_ID'] ?>

            <div id="innerHeaderContent">

                <div id="headerContent">

                    <div id="logo">

                        <a href="index.php"><img src="images/logo.png" /></a>

                    </div>

                    <div id="headerRightsideContent">

                        <div> Bem-vindo <?php echo $_SESSION['firstname']; ?>  <span class="sep">|</span>  <a href="logout.php">Sair</a></div>

                        <div class="time" ><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'NameofShop'); ?> &nbsp;<span id="dv"></span></div>

                    </div>

                </div>

                <div id="navigationPanel">

                    <div class="session">

                        <?php if ($Get_XML_Responce->readXmlArrtibut('content.xml', 'Dashboard') != '') {

                        ?>

                            <li><a href="index.php" class="dashboard"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Dashboard'); ?></a></li>

                        <?php } else {

 ?>

                            <li><a href="index.php" class="dashboard"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Dashboard'); ?></a></li>

<?php } ?>

                    <!--<li><a href="#" class="inventor"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Inventor'); ?></a></li>

                    <li><a href="#" class="Managment"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Managment'); ?></a></li>

                    <li><a href="#" class="report"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Report'); ?></a></li>   -->

<?php if ($_SESSION['usertype'] == 'Admin') { ?>



                            <li><a href="cat_edit.php" class="support"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Category'); ?></a></li>

<?php } ?>

                        <!--<li><a href="#" class="help">Help </a></li>-->



<?php if ($_SESSION['usertype'] == 'Admin') { ?>



                            <li><a href="products_management.php" class="products"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Products'); ?></a></li>

<?php } ?>







                        <?php

                        if ($_SESSION['usertype'] == 'Admin') {

                            if ($Get_XML_Responce->readXmlArrtibut('content.xml', 'Users') != '') {

                        ?>

                                <li><a href="order_parchase.php" class="report"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Create_Order'); ?></a></li>

<?php } else { ?>



                                <li><a href="order_parchase.php" class="report"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Create_Order'); ?></a></li>

                        <?php }

                        } ?>



                        <li><a href="stock_out.php" class="inventor"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Stock_Out'); ?> </a></li>





<?php if ($_SESSION['usertype'] == 'Admin') { ?>



                            <li><a href="report.php" class="report2"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Report'); ?></a></li>



<?php } ?>



                        <?php

                        if ($_SESSION['usertype'] == 'Admin') {

                            if ($Get_XML_Responce->readXmlArrtibut('content.xml', 'Users') != '') {

                        ?>

                                <li><a href="user_management.php" class="user"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Users'); ?></a></li>

                        <?php } else { ?>

                                <li><a href="user_management.php" class="user"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Users'); ?></a></li>

                        <?php }

                        } ?>



                        <?php if ($_SESSION['usertype'] == 'Admin') {

                        ?>

                            <li style="background:none;"><a href="day_magage_report.php" class="DayManage"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Monthly_Hours'); ?></a></li>

                        <?php } ?>





                        <?php if ($_SESSION['usertype'] != 'Admin') {

 ?>

                            <li style="background:none;"><a href="day_manage.php" class="DayManage"><?php echo $Get_XML_Responce->readXmlArrtibut('content.xml', 'Monthly_Hours_Management'); ?></a></li>

<?php } ?>



                    </div>

                </div>

            </div>

        </div>