# -*- coding: utf-8 -*- 
<%inherit file="jm2l:templates/layout.mako"/>
<%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
<%def name="jsAddOn()">
  <script src="/js/jm2l.js"></script>
  <script src="/vendor/ckeditor/ckeditor.js"></script>
  <script src="/vendor/select2/js/select2.js"></script>  
  <script src="/vendor/datepicker/bootstrap-datepicker.js"></script>
  <script type="text/javascript">
    var checkout = $('#due_date').datepicker({
            format: "dd/mm/yyyy"
	})
    .on('changeDate', function(ev) {
    	    checkout.hide();
    	}).data('datepicker');
  </script>
</%def>
<%def name="cssAddOn()">
  <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">
  <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui.css">
  <link rel="stylesheet" href="/css/jm2l.css" />
  <link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" />
  <link rel="stylesheet" href="/vendor/datepicker/datepicker.css" type="text/css" media="screen" />
  <!-- CSS adjustments for browsers with JavaScript disabled -->
  <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-noscript.css"></noscript>
  <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui-noscript.css"></noscript>  
</%def>

<div class="row-fluid">
  <div class="span10 offset1">

<a class="btn" href="${request.route_path('list_task', year=year, _anchor=area)}">
    <i class="icon-arrow-left"></i> Retour à la liste
</a>
% if 'uid' in form._fields.keys():
<a class="btn btn-danger btn-mini pull-right" onclick="return confirm_click();" href="${request.route_path('action_task', year=year, action='delete', task_id=form.uid.data)}">
    <i class="icon-remove icon-white"></i> Supprimer cette tâche
</a>
%endif

% if 'uid' in form._fields.keys():
    <h3>Editer une tâche</h3>
% else:
    <h3>Ajouter une tâche</h3>
%endif


<%
DicForm = { 
    'name':         {'PlaceHolder':u"Nom de la tâche",  "FieldStyle":"width:90%;" },
    'area_uid':     {"FieldStyle":"width:16em;", 'ContainerStyle':"float:left;" },
    'closed_by':    {"FieldStyle":"width:16em;", 'ContainerStyle':"float:left;" },
    'due_date':     {'PlaceHolder':u"27/11/2017", "FieldStyle":"width:8em;"},
    'description':  {'PlaceHolder':u"Description",      "FieldStyle":"width:95%;min-height:150px;", "ckeditor":"1" },
    }
%>

% if 'uid' in form._fields.keys():
    <form action="/${year}/Staff/tasks/${form.uid.data}" method="post">
    ${form.uid()}
%else:
    <form action="/${year}/Staff/tasks" method="post">
%endif
    ${helpers.DisplayForm(form, DicForm)}

<br>
<div class="center">
    <button type="submit" class="btn btn-large btn-primary" />
        <i class="icon-ok icon-white"></i> Enregistrer
    </button>
</div>

</form>
% if 'uid' in form._fields.keys():
<div class="center">
    ${helpers.uploader("tasks", form.uid.data, u"une pièce jointe" )}
</div>
%endif

  </div>
</div>
