通过从其他网站页面传递日期来调用FullCalendar - Odoo V10

时间:2017-04-17 02:25:47

标签: fullcalendar odoo-10

我已使用以下源代码

向Odoo网站主页显示完整日历
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <data noupdate="1">

        <!-- Banner -->
        <template inherit_id="website.homepage" id="homepage_inherit">
            <xpath expr="//div[@id='wrap']" position="replace">
            <link rel='stylesheet' href='/fullcalendar/fullcalendar.css' />
            <script  type="text/javascript" src='/fullcalendar/lib/jquery.min.js'></script>
            <script   type="text/javascript" src='/fullcalendar/lib/moment.min.js'></script>
            <script   type="text/javascript" src='/fullcalendar/fullcalendar.js'></script>

        <script type="text/javascript">

        /*
            jQuery document ready
        */

        $(document).ready(function()
        {
            /*
                date store today date.
                d store today date.
                m store current month.
                y store current year.
            */
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();

            /*
                Initialize fullCalendar and store into variable.
                Why in variable?
                Because doing so we can use it inside other function.
                In order to modify its option later.
            */

            var calendar = $('#calendar').fullCalendar(
            {
                /*
                    header option will define our calendar header.
                    left define what will be at left position in calendar
                    center define what will be at center position in calendar
                    right define what will be at right position in calendar
                */
                header:
                {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                /*
                    defaultView option used to define which view to show by default,
                    for example we have used agendaWeek.
                */
                defaultView: 'agendaWeek',
                /*
                    selectable:true will enable user to select datetime slot
                    selectHelper will add helpers for selectable.
                */
                selectable: true,
                selectHelper: true,
                /*
                    when user select timeslot this option code will execute.
                    It has three arguments. Start,end and allDay.
                    Start means starting time of event.
                    End means ending time of event.
                    allDay means if events is for entire day or not.
                */
                select: function(start, end, allDay)
                {
                    /*
                        after selection user will be promted for enter title for event.
                    */
                    var title = prompt('Event Title:');
                    /*
                        if title is enterd calendar will add title and event into fullCalendar.
                    */
                    if (title)
                    {
                        calendar.fullCalendar('renderEvent',
                            {
                                title: title,
                                start: start,
                                end: end,
                                allDay: allDay
                            },
                            true // make the event "stick"
                        );
                    }
                    calendar.fullCalendar('unselect');
                },
                /*
                    editable: true allow user to edit events.
                */
                editable: true,
                /*
                    events is the main option for calendar.
                    for demo we have added predefined events in json object.
                */
                events: [
                    {
                        title: 'All Day Event',
                        start: new Date(y, m, 1)
                    },
                    {
                        title: 'Long Event',
                        start: new Date(y, m, d-5),
                        end: new Date(y, m, d-2)
                    },
                    {
                        id: 999,
                        title: 'Repeating Event',
                        start: new Date(y, m, d-3, 16, 0),
                        allDay: false
                    },
                    {
                        id: 999,
                        title: 'Repeating Event',
                        start: new Date(y, m, d+4, 16, 0),
                        allDay: false
                    },
                    {
                        title: 'Meeting',
                        start: new Date(y, m, d, 10, 30),
                        allDay: false
                    },
                    {
                        title: 'Lunch',
                        start: new Date(y, m, d, 12, 0),
                        end: new Date(y, m, d, 14, 0),
                        allDay: false
                    },
                    {
                        title: 'Birthday Party',
                        start: new Date(y, m, d+1, 19, 0),
                        end: new Date(y, m, d+1, 22, 30),
                        allDay: false
                    },
                    {
                        title: 'Click for Google',
                        start: new Date(y, m, 28),
                        end: new Date(y, m, 29),
                        url: 'http://google.com/'
                    }
                ]
            });

        });
            </script>
            <div id='calendar'></div>
            </xpath>
        </template>
  </data>
</odoo>

现在我需要从联系人页面导航到主页有一些日期,日历应该加载带有日期的日视图,

 <template inherit_id="website.contactus" id="contactus_inherit">
            <xpath expr="//div[@id='wrap']" position="replace">
            <div class="text-center mt64" name="mail_button">
                        <a t-attf-href="#" onclick="alert('test');
                     var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();
            var n = new Date(y, m, d-3);
                                    window.href = '/homepage';
                                    $('#calendar').fullCalendar( 'gotoDate', n)" class="btn btn-primary" id="o_contact_mail">Send us an email</a>
             </div>
           </xpath>
        </template> 

如上所述调用会抛出“$ .. fullcalendar不是函数”错误。 我怎样才能做到这一点 ?请有人给我一个进一步推进的想法!!!

0 个答案:

没有答案