<!-- BEGIN {$smarty.template} -->
<script type="text/javascript" src="js/tasks.js"></script>
<script type="text/javascript" src="js/table.js"></script>

{include file="delete_operation.tpl.js"}

<div id="opdetails"> </div>
<div id="editopdetails">{include file="add_operation_div.tpl.html"}</div>

{if count($operations) > 0}
<div class="dcaption"><em>{t 1=$curryear}My manhours [%1]{/t}</em>&nbsp;</div>

<div class="floatcontainer">
<div id="mhchartyear" class="flleft mhchart"></div>
<div id="mhchartmonth" class="flleft mhchart"></div>
</div>
<div class="spacer"></div>

<script type="text/javascript" >
    {literal}
    $(document).ready(function() {

        $.getJSON("data_service.php?req=mhrs&pe_id={/literal}{$PE_ID}&type={$smarty.const.PHPAGA_MANHOURS_DISPLAY_YEAR}{literal}",
                 function(data){  
                     ticks = [];
                     $.each(data.ticks, function(i,item){ ticks.push(String(item)); });

                     calweekmhplot = $.jqplot('mhchartyear', [data.values], {
                        title: data.title, 
                        grid: { borderWidth: 0, gridLineColor: '#dddddd', shadow: false },
                        seriesDefaults:{
                            renderer:$.jqplot.BarRenderer, 
                            rendererOptions:{barPadding: 2, barMargin: 2},
                            shadow: false,
                        },
                        axes:{
                            xaxis:{
                                renderer:$.jqplot.CategoryAxisRenderer,
                                rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer },
                                ticks: ticks,
                                tickOptions: { angle: -90 },
                                label: data.xlabel,
                                },
                            yaxis: { autoscale:true, min:0, tickOptions:{formatString:'%d'} },
                        },
                        highlighter: {sizeAdjust: 7.5, useAxesFormatters:false, tooltipAxes: 'y'},
                    });

                });

        $.getJSON("data_service.php?req=mhrs&pe_id={/literal}{$PE_ID}&type={$smarty.const.PHPAGA_MANHOURS_DISPLAY_MONTH}{literal}",
                 function(data){  
                     ticks = [];
                     dmin = null;
                     dmax = null;
                     $.each(data.ticks, function(i,item){ d = Date.parse(item); ticks.push(d.toString('d')); });

                     daymhplot = $.jqplot('mhchartmonth', [data.values], {
                        title: data.title,//'{/literal}{t}Daily manhours{/t}{literal} '+period, 
                        grid: { borderWidth: 0, gridLineColor: '#dddddd', shadow: false },
                        seriesDefaults:{
                            renderer:$.jqplot.BarRenderer, 
                            //rendererOptions:{barPadding: 8, barMargin: 20}
                            shadow: false,
                        },
                        axes:{
                            xaxis:{
                                renderer:$.jqplot.CategoryAxisRenderer,
//                                rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer },
                                ticks: ticks,
//                                tickOptions: { angle: -90 },
                                label: data.xlabel,
                                },
                            yaxis: { autoscale:true, min:0, tickOptions:{formatString:'%d'} },
                        },
                        highlighter: {sizeAdjust: 7.5, useAxesFormatters:false, tooltipAxes: 'y'},

                    });

                    });
    });
{/literal}
</script>
{/if}

<form action="{$smarty.const.PHPAGA_SELF}" method="get">
    <table class="table-autosort table-autostripe table-stripeclass:even" cellspacing="0">
        <caption><em>{t}My projects and projects I'm a member of{/t}</em>
            {t}Status{/t}:
            <select name="prj_status" onchange="this.form.submit();">
                {html_options options=$prjstat selected=$prjstat_sel}
            </select>
        </caption>

        <thead>
            <tr>
                <th class="table-sortable:default"> {t}Title{/t} </th>
                <th class="table-sortable:default"> {t}Status{/t} </th>
                <th class="table-sortable:default"> {t}Customer{/t} </th>
                <th class="table-sortable:default"> {t}Prio.{/t} </th>
                <th class="table-sortable:date"> {t}Start date{/t} </th>
                <th class="table-sortable:date"> {t}Deadline{/t} </th>
                <th class="table-sortable:default"> {t}Category{/t} </th>
                <th class="table-sortable:numeric_colon"> {t}Hours{/t} </th>
                <th> {t}Actions{/t} </th>
            </tr>
        </thead>

        {if (count($projects) > 0)}
        <tbody>
            {section name=pdetails loop=$projects}
            <tr>
                <td{if ((strlen($projects[pdetails].prj_title) > $smarty.const.PHPAGA_SHOWPRJTITLELENGHT))} class="tTip" title="{$projects[pdetails].prj_title|phpaga_popup_sanitizestr}"{/if}>
                    <a href="project.php?id={$projects[pdetails].prj_id}">{$projects[pdetails].prj_title|wash|trnc:$smarty.const.PHPAGA_SHOWPRJTITLELENGHT:"...":true}</a>
                </td>
                <td> {$projects[pdetails].prjstat_title|wash} </td>
                <td> <a href="company.php?id={$projects[pdetails].cpn_id}">{$projects[pdetails].cpn_name|wash}</a> </td>
                <td class="time"> {$projects[pdetails].prj_priority|wash|default:"&nbsp;"} </td>
                <td class="time"> {$projects[pdetails].prj_startdate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
                <td{if $projects[pdetails].prj_overdue} class="overdue"{/if}> {if strlen($projects[pdetails].prj_deadline)}{$projects[pdetails].prj_deadline|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}{else}&nbsp;{/if} </td>
                <td> {$projects[pdetails].prjcat_title|wash} </td>
                <td class="time" id="dur{$projects[pdetails].prj_id}"> {if (strlen($projects[pdetails].prj_duration) && ($projects[pdetails].prj_duration > 0))}{$projects[pdetails].prj_duration|phpaga_minutes2duration}{else}&nbsp;{/if} </td>
                <td class="actions"> <a href="add_operation.php?prj_id={$projects[pdetails].prj_id}" class="ptr" onclick="addTask({$projects[pdetails].prj_id}, 'pimg', {$current_pe_id}); return false;"><img id="pimg{$projects[pdetails].prj_id}" src="img/phpaga/task_add.png" height="16" width="16" border="0" alt="{t}Add task{/t}" title="{t}Add task{/t}"></a> </td>
            </tr>
            {/section}
        </tbody>
        {else}
        <tr>
            <td colspan="9">
                {if strlen($prjstat_sel_name)}
                {t}You have not created any projects and you are not a member of any existing project with the selected status.{/t}
                {else}
                {t}You have not created any projects and you are not a member of any existing project.{/t}
                {/if}
            </td>
        </tr>
        {/if}
    </table>
</form>

{if count($operations)}
<table class="table-autosort table-autostripe table-stripeclass:even" cellspacing="0" id="lop">
    <caption><em>{t 1=$num_lastoperations}My last %1 tasks{/t}</em></caption>

    <thead>
        <tr>
            <th class="table-sortable:default"> {t}Project{/t} </th>
            <th class="table-sortable:default"> {t}Task{/t} </th>
            <th class="time table-sortable:date"> {t}Date{/t} </th>
            <th class="table-sortable:default"> {t}Category{/t} </th>
            <th class="table-sortable:numeric_colon"> {t}Hours{/t} </th>
            <th> {t}Actions{/t} </th>
        </tr>
    </thead>
    <tbody>
        {section name=details loop=$operations}
        <tr>
            <td{if ((strlen($operations[details].prj_title) > $smarty.const.PHPAGA_SHOWPRJTITLELENGHT))} class="tTip" title="{$operations[details].prj_title|phpaga_popup_sanitizestr}"{/if}>
                <a href="project.php?id={$operations[details].prj_id}">{$operations[details].prj_title|wash|trnc:$smarty.const.PHPAGA_SHOWPRJTITLELENGHT:"..."}</a>
            </td>
            <td{if ((strlen($operations[details].op_desc) > $smarty.const.PHPAGA_SHOWOPDESCLENGHT))} class="tTip" title="{$operations[details].op_desc|wash|phpaga_popup_sanitizestr}"{/if}>
                {$operations[details].op_desc|wash|trnc:$smarty.const.PHPAGA_SHOWOPDESCLENGHT:"..."}
            </td>
            <td class="time"> {$operations[details].op_startdate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
            <td> {$operations[details].opcat_title|wash} </td>
            <td class="time"> {$operations[details].op_duration_hrs} </td>
            <td class="actions"> {strip}
                <a class="ptr" onclick="viewTaskDetails({$operations[details].op_id}, 'vimg')"><img id="vimg{$operations[details].op_id}" src="img/phpaga/view.png" height="16" width="16" border="0" alt="{t}View{/t}" title="{t}View{/t}"></a>
                {if ($operations[details].op_canedit)}
                <a href="operation.php?id={$operations[details].op_id}&amp;ref=main.php"><img src="img/phpaga/edit.png" height="16" width="16" border="0" alt="{t}Edit{/t}" title="{t}Edit{/t}"></a>
                <a class="ptr" onclick="confirm_delete_op({$operations[details].op_id}, '{$operations[details].op_startdate|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}\n{t}Project{/t}: {$operations[details].prj_title}\n{t}Task{/t}: {$operations[details].op_desc|phpaga_jsmessage_sanitizestr}');"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
                {elseif $perm_view_invoices}
                <a href="bill.php?id={$operations[details].bill_id}"><img src="img/phpaga/bill.png" height="16" width="16" border="0" alt="{t}View invoice{/t}" title="{t}View invoice{/t}"></a>
                {/if}
                {/strip}
            </td>
        </tr>
        {/section}
    </tbody>
</table>
{/if}

<!-- END {$smarty.template} -->
