Author: meynier Date: 2013-06-27 16:07:10 +0200 (Thu, 27 Jun 2013) New Revision: 348 Url: http://chorem.org/projects/chorem/repository/revisions/348 Log: Project dashboard : UI changes + filter for the quotations Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java trunk/chorem-webmotion/src/main/resources/mapping trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp trunk/chorem-webmotion/src/main/webapp/css/jquery.fn.gantt.css trunk/chorem-webmotion/src/main/webapp/js/chorem.js trunk/chorem-webmotion/src/main/webapp/js/jquery.fn.gantt.js Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-06-26 09:30:51 UTC (rev 347) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-06-27 14:07:10 UTC (rev 348) @@ -2,9 +2,13 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.TreeMap; import org.apache.commons.logging.Log; @@ -14,9 +18,12 @@ import org.chorem.ChoremUtil; import org.debux.webmotion.server.call.Call; import org.debux.webmotion.server.render.Render; +import org.chorem.entities.Closed; import org.chorem.entities.Quotation; import org.chorem.entities.Project; import org.chorem.entities.Task; +import org.chorem.entities.TaskStatus; +import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.entities.WikittyExtension; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; @@ -32,14 +39,13 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(DashboardProjectAction.class); - public Render projectFilter(ChoremClient client, String id) { + public Render projectFilter(ChoremClient client, String id, String quotationFilter) { WikittyQueryResult<Project> projectResult = null; WikittyQueryResult<Quotation> quotationResult = null; WikittyQueryResult<Task> taskResult = null; HashMap<Quotation, List<Task>> taskMap = new HashMap<Quotation, List<Task>>(); - HashMap<Quotation, String> jSonTaskMap = new HashMap<Quotation, String>(); //HashMap<Quotation, String> extMap = new HashMap<Quotation, String>(); //Fetch the project form the name (if it has been requested) @@ -53,10 +59,22 @@ //Fetch the quotations form the project (if there is one) if(projectResult.size() != 0) { for(Project project : projectResult.getAll()) { - WikittyQuery quotationQuery = new WikittyQueryMaker() - .eq(Quotation.ELEMENT_FIELD_QUOTATION_PROJECT, project) - .end(); + WikittyQuery quotationQuery = null; + WikittyQueryMaker wqm = new WikittyQueryMaker(); + + if(quotationFilter.equals("Devis ouverts")) { + wqm.and() + .eq(Quotation.ELEMENT_FIELD_QUOTATION_PROJECT, project) + .extne(Closed.EXT_CLOSED); + } + else { + wqm.eq(Quotation.ELEMENT_FIELD_QUOTATION_PROJECT, project); + } + + quotationQuery = wqm.end(); + + quotationQuery.addSortDescending(Quotation.ELEMENT_FIELD_INTERVAL_BEGINDATE); quotationResult = client.findAllByQuery(Quotation.class, quotationQuery); @@ -66,6 +84,7 @@ //Fetch the tasks form the quotations (if there are some) if(quotationResult != null) { + String customClass = ""; for(Quotation quote : quotationResult.getAll()) { WikittyQuery taskQuery = new WikittyQueryMaker() .eq(Task.ELEMENT_FIELD_TASK_QUOTATION, quote) @@ -73,22 +92,12 @@ taskResult = client.findAllByQuery(Task.class, taskQuery); taskMap.put(quote, taskResult.getAll()); - List<JTask> lTask = new ArrayList<JTask>(); - for(Task t : taskResult.getAll()) { - Values[] v = new Values[1]; - v[0] = new Values(t.getBeginDate(), t.getEndDate(), t.getName(), "ganttRed"); - JTask jt = new JTask(t.getName(), t.getDescription(), v); - - lTask.add(jt); - } - Gson g = new Gson(); - jSonTaskMap.put(quote, g.toJson(lTask)); + } } } - System.out.println(taskMap); if(projectResult == null) { return renderView("dashboardSingleProject.jsp", @@ -102,51 +111,123 @@ else { return renderView("dashboardSingleProject.jsp", "title", "Tableau de bord projet", "projects", projectResult.getAll(), - "quotations", quotationResult.getAll(), "taskMap", taskMap,"jSonTaskMap",jSonTaskMap, "extensions", + "quotations", quotationResult.getAll(), "taskMap", taskMap, "extensions", Extensions.extensions); } } - public Render requestProject(ChoremClient client, String project_id) { - return projectFilter(client, project_id); + public Render requestProject(ChoremClient client, String project_id, String quotationFilter) { + return projectFilter(client, project_id, quotationFilter); } - - /* - private String getNextExtension(ChoremClient client,Quotation object) { - Collection<String> extensions = object.getExtensionNames(); + public Render getGanttInfo(ChoremClient client, String id) { + Wikitty wikitty = client.restore(id); + WikittyQuery quotationQuery = new WikittyQueryMaker() + .ideq(id) + .end(); + Quotation quotation = client.findByQuery(Quotation.class, quotationQuery); + + + + WikittyQuery taskQuery = new WikittyQueryMaker() + .eq(Task.ELEMENT_FIELD_TASK_QUOTATION, quotation) + .end(); + WikittyQueryResult<Task> taskResult = client.findAllByQuery(Task.class, taskQuery); + String customClass = ""; + List<JTask> lTask = new ArrayList<JTask>(); + for(Task t : taskResult.getAll()) { + + if(t.getStatus().equals("SCHEDULED")) { + customClass = "ganttBlue"; + } + else if(t.getStatus().equals("STARTED")) { + customClass = "ganttGreen"; + } + else if(t.getStatus().equals("FINISHED")) { + customClass = "ganttRed"; + } + else if(t.getStatus().equals("CLOSED")) { + customClass = "ganttGrey"; + } + + Values[] v = null; + if(t.getReestimatedEnd() != null) + v= new Values[2]; + else + v = new Values[1]; + v[0] = new Values(t.getBeginDate(), t.getEndDate(), t.getName(), customClass); + if(t.getReestimatedEnd() != null) + v[1]= new Values(t.getEndDate(), t.getReestimatedEnd(), "Reestimated end", "ganttOrange"); + + JTask jt = new JTask(t.getName(), t.getDescription(), v); + + lTask.add(jt); + } - if(extensions.contains("Closed")) return null; + Collections.sort(lTask); + String dateStart = "/Date(" + quotation.getBeginDate().getTime() + ")/"; + String dateEnd = "/Date(" + quotation.getEndDate().getTime() + ")/"; + + HashMap<String,String> dateMap = new HashMap<String,String>(); + dateMap.put("sendingDate", "Draft"); + dateMap.put("postedDate", "Sent"); + dateMap.put("acceptedDate", "Accepted"); + dateMap.put("startedDate", "Started"); + dateMap.put("deliveryDate", "Delivered"); + dateMap.put("rsvStart", "RSV"); + dateMap.put("warrantyStart", "Warranty"); + dateMap.put("closedDate", "Closed"); + dateMap.put("rejectedDate", "Rejected"); + dateMap.put("cancelledDate", "Cancelled"); - TreeMap<Integer, String> extMap = new TreeMap<Integer, String>(); - - - - //reverse loop - for(int i = exts.length-1; i>=0; i--) { - if(extensions.contains(exts[i])) { - WikittyExtension ret = client.restoreExtensionLastVersion(exts[i+1]); - return ret; + Iterator i = dateMap.entrySet().iterator(); + HashMap<String,String> extDate = new HashMap<String,String>(); + while(i.hasNext()) { + Map.Entry<String, String> me = (Map.Entry<String, String>)i.next(); + if(wikitty.hasExtension(me.getValue())) { + extDate.put( + me.getValue() + " " + me.getKey(), + "/Date(" + ((Date) (wikitty.getFieldAsObject(me.getValue(), me.getKey()))).getTime() +")/"); } - } - return null; - }*/ + JRender data = new JRender(lTask, extDate, dateStart, dateEnd); + return renderJSON("data", data); + } - private class JTask { + + private class JRender { + private List<JTask> source; + private String dateStart; + private String dateEnd; + private HashMap<String,String> extDate; + public JRender(List<JTask> source,HashMap<String,String> extDate,String dateStart,String dateEnd) { + this.source = source; + this.dateStart = dateStart; + this.dateEnd = dateEnd; + this.extDate = extDate; + } + } + + private class JTask implements Comparable { private String name; private String desc; private Values[] values; + private String status; public JTask(String name, String desc, Values[] values) { this.name = name; this.desc = desc; this.values = values; } + @Override + public int compareTo(Object task) { + + return values[0].compareTo(((JTask)task).values[0]); + } } - private class Values{ + private class Values implements Comparable{ private String from; private String to; private String label; @@ -157,6 +238,21 @@ this.label = label; this.customClass = customClass; } + @Override + public int compareTo(Object o) { + + return from.compareTo(((Values)o).from); + } } + + private class QuotationSorter<T> implements Comparator { + + @Override + public int compare(Object q1, Object q2) { + + return ((Quotation)q1).getBeginDate().compareTo(((Quotation)q2).getBeginDate()); + } + + } } Modified: trunk/chorem-webmotion/src/main/resources/mapping =================================================================== --- trunk/chorem-webmotion/src/main/resources/mapping 2013-06-26 09:30:51 UTC (rev 347) +++ trunk/chorem-webmotion/src/main/resources/mapping 2013-06-27 14:07:10 UTC (rev 348) @@ -69,6 +69,7 @@ * /sales/funnel/json/{method} action:sales.SalesAction.{method} * /sales/funnel/json/{method}/{id} action:sales.SalesAction.{method} * /project action:project.DashboardProjectAction.requestProject -* /project/json/{method}/{extensionName}/{id} action:project.QuotationStatusAction.{method} +* /project/json/getExtension/{extensionName}/{id} action:project.QuotationStatusAction.getExtension +* /project/json/getGanttInfo/{id} action:project.DashboardProjectAction.getGanttInfo * /crm/account/{id} action:crm.AccountAction.view * /crm/quotation/edit/{id} action:crm.QuotationAction.edit Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-06-26 09:30:51 UTC (rev 347) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-06-27 14:07:10 UTC (rev 348) @@ -56,7 +56,14 @@ <input type="text" id="project_text" name="project_name" value="${param.project_name}" placeholder="project name" /> <input - type="hidden" id="project_hidden" name="project_id" value="" /> + type="hidden" id="project_hidden" name="project_id" + value="${param.project_id}" /> <select class="filterBox" + name="quotationFilter" id="quotationFilter"> + <option name="open">Devis ouverts</option> + <option name="all" + <c:if test='${param.quotationFilter=="Tous les devis" }'>selected</c:if>>Tous + les devis</option> + </select> </div> </div> @@ -64,20 +71,38 @@ <c:choose> <c:when test="${projects.size() >= 1}"> - <c:forEach var="p" items="${projects}"> - <h2>${p.name}</h2> + <h2 style="display: inline;">${p.name}</h2> + <a href="<c:url value="/wikitty/edit/${param.project_id}"/>"><i + class="icon-pencil icon-black"></i><small>edit</small></a> <p>${p.description}</p> </c:forEach> -<script>var ganttData = new Array();</script> <c:forEach var="q" items="${quotations}"> + + <h3 style="display: inline;"> + <w:display wikitty="${q.wikitty}" fqfield="Quotation.description" + label="" /> + </h3> + <a href="<c:url value="/wikitty/edit/${q.wikittyId}"/>"><i + class="icon-pencil icon-black"></i><small>edit</small></a> + <p> + Du <w:display wikitty="${q.wikitty}" fqfield="Interval.beginDate" + label="" pattern="dd/MM/yyyy"/> + au <w:display wikitty="${q.wikitty}" fqfield="Interval.beginDate" + label="" pattern="dd/MM/yyyy" /> + <br />Statut : + ${q.wikitty.extensionNames.toArray()[q.wikitty.extensionNames.size() + -1]} + </p> + + + <table class="table table-striped table-bordered table-condensed"> <thead> <tr> - <th>Devis</th> <th>Responsable Code Lutin</th> <th>Responsable entreprise</th> <th>Estimated days</th> @@ -90,9 +115,8 @@ <tbody> <tr> + <td><w:display wikitty="${q.wikitty}" - fqfield="Quotation.description" label="" /></td> - <td><w:display wikitty="${q.wikitty}" fqfield="Quotation.supplier" label="" /></td> <td><w:display wikitty="${q.wikitty}" fqfield="Quotation.customer" label="" /></td> @@ -108,48 +132,12 @@ </tbody> </table> + + <div class="gantt gantt-${q.wikittyId}" wikittyId = "${q.wikittyId}" data=''> + Pas de tâche</div> +<!-- - <p> - Début : ${q.beginDate}<br /> Fin : - <w:display wikitty="${q.wikitty}" fqfield="Interval.endDate" - label="" /> - </p> - <a class="ganttinit" wikittyId="${q.wikittyId}" href="#">Afficher Gantt</a> - <div class="gantt-${q.wikittyId}" data =''></div> - - <c:set var="script" value="ganttData['${q.wikittyId}'] = {src:${jSonTaskMap[q]}, - startDate:'/Date(${q.beginDate.time})/', - endDate:'/Date(${q.endDate.time})/' - "/> - - <% - java.util.HashMap<String,String> dateMap = new java.util.HashMap<String,String>(); - dateMap.put("sendingDate", "Draft"); - dateMap.put("postedDate", "Sent"); - dateMap.put("acceptedDate", "Accepted"); - dateMap.put("startedDate", "Started"); - dateMap.put("deliveryDate", "Delivered"); - dateMap.put("rsvStart", "RSV"); - dateMap.put("warrantyStart", "Warranty"); - dateMap.put("closedDate", "Closed"); - dateMap.put("rejectedDate", "Rejected"); - dateMap.put("cancelledDate", "Cancelled"); - pageContext.setAttribute("dateMap", dateMap); - %> - - <c:forEach items="${dateMap}" var="entry"> - <c:if test='${q.wikitty.hasExtension(entry.value)}'> - <c:set var="script" value="${script},${entry.key} :'/Date(${q.wikitty.getFieldAsObject(entry.value, entry.key).time})/'"/> - </c:if> - </c:forEach> - - <c:set var="script" value="${script}};"/> - - <script> - ${script} - </script> - <p>Liste des tâches :</p> <c:forEach items="${taskMap}" var="entry"> <c:if test="${entry.key.equals(q)}"> @@ -182,8 +170,8 @@ </select> </p> <div id="upgradeFields-${q.wikittyId}"></div> +--> - </c:forEach> </c:when> Modified: trunk/chorem-webmotion/src/main/webapp/css/jquery.fn.gantt.css =================================================================== --- trunk/chorem-webmotion/src/main/webapp/css/jquery.fn.gantt.css 2013-06-26 09:30:51 UTC (rev 347) +++ trunk/chorem-webmotion/src/main/webapp/css/jquery.fn.gantt.css 2013-06-27 14:07:10 UTC (rev 348) @@ -248,7 +248,13 @@ color: #714715 !important; } +.fn-gantt .ganttBlue { + background-color: #88ccff; +} +.fn-gantt .ganttGrey { + background-color: #cccccc; +} /* === BOTTOM NAVIGATION === */ .fn-gantt .bottom { Modified: trunk/chorem-webmotion/src/main/webapp/js/chorem.js =================================================================== --- trunk/chorem-webmotion/src/main/webapp/js/chorem.js 2013-06-26 09:30:51 UTC (rev 347) +++ trunk/chorem-webmotion/src/main/webapp/js/chorem.js 2013-06-27 14:07:10 UTC (rev 348) @@ -97,38 +97,38 @@ /*********** SALES FUNNEL FUNCTIONS**********************/ function leadToDraft(){ - var id = $(this).attr('wikittyId'); - var oldQuotation = $(this).parent(); - $("#lead-wikittyId").val(id); - $("#dialog-form-leadToDraft" ).data("oldQuotation", oldQuotation).dialog( "open" ); + var id = $(this).attr('wikittyId'); + var oldQuotation = $(this).parent(); + $("#lead-wikittyId").val(id); + $("#dialog-form-leadToDraft" ).data("oldQuotation", oldQuotation).dialog( "open" ); }; function draftToSent(){ - var id = $(this).attr('wikittyId'); - var oldQuotation = $(this).parent(); - $("#draft-wikittyId").val(id); - $("#dialog-form-draftToSent" ).data("oldQuotation", oldQuotation).dialog( "open" ); + var id = $(this).attr('wikittyId'); + var oldQuotation = $(this).parent(); + $("#draft-wikittyId").val(id); + $("#dialog-form-draftToSent" ).data("oldQuotation", oldQuotation).dialog( "open" ); }; function sentToAccepted(){ - var id = $(this).attr('wikittyId'); - var oldQuotation = $(this).parent(); - $("#sent-wikittyId").val(id); - $("#dialog-form-sentToAccepted" ).data("oldQuotation", oldQuotation).dialog( "open" ); + var id = $(this).attr('wikittyId'); + var oldQuotation = $(this).parent(); + $("#sent-wikittyId").val(id); + $("#dialog-form-sentToAccepted" ).data("oldQuotation", oldQuotation).dialog( "open" ); }; function sentToRejected(){ - var id = $(this).attr('wikittyId'); - var oldQuotation = $(this).parent(); - $("#rejected-wikittyId").val(id); - $("#dialog-form-sentToRejected" ).data("oldQuotation", oldQuotation).dialog( "open" ); + var id = $(this).attr('wikittyId'); + var oldQuotation = $(this).parent(); + $("#rejected-wikittyId").val(id); + $("#dialog-form-sentToRejected" ).data("oldQuotation", oldQuotation).dialog( "open" ); }; function toCancelled(){ - var id = $(this).attr('wikittyId'); - var oldQuotation = $(this).parent(); - $("#cancelled-wikittyId").val(id); - $("#dialog-form-toCancelled" ).data("oldQuotation", oldQuotation).dialog( "open" ); + var id = $(this).attr('wikittyId'); + var oldQuotation = $(this).parent(); + $("#cancelled-wikittyId").val(id); + $("#dialog-form-toCancelled" ).data("oldQuotation", oldQuotation).dialog( "open" ); }; //ajout ble @@ -270,447 +270,447 @@ // * SALES FUNNEL * // ******************************************************************** - - //Passage d'un lead -> draft - $("a.lead").click(leadToDraft); - $( "#dialog-form-leadToDraft" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - Ok: function() { + //Passage d'un lead -> draft + $("a.lead").click(leadToDraft); - var reference = $("#reference").val(); - var sendingDate = $("#sendingDate").val(); - var id = $("#lead-wikittyId").val(); - var oldQuotation = $(this).data('oldQuotation'); - var allFields = $([]).add($("#reference")).add($("#sendingDate")).add($("#lead-wikittyId")) + $( "#dialog-form-leadToDraft" ).dialog({ + autoOpen: false, + height: 300, + width: 350, + modal: true, + buttons: { + Ok: function() { - var dialog = $( this ); + var reference = $("#reference").val(); + var sendingDate = $("#sendingDate").val(); + var id = $("#lead-wikittyId").val(); + var oldQuotation = $(this).data('oldQuotation'); + var allFields = $([]).add($("#reference")).add($("#sendingDate")).add($("#lead-wikittyId")) - $.post(createUrl("/sales/funnel/json/answer/", id,"?sendingDate=", sendingDate, "&reference=",reference), - function(data){ - //success - var wikittyId = data.meta.id; - var wikitty = data.data; + var dialog = $( this ); - var li = $("<li></li>").addClass("salesFunnelItem draft"); + $.post(createUrl("/sales/funnel/json/answer/", id,"?sendingDate=", sendingDate, "&reference=",reference), + function(data){ + //success + var wikittyId = data.meta.id; + var wikitty = data.data; - //leftDiv - var leftDiv = $("<div></div>").addClass("pull-left"); - var aIconEdit = $("<a></a>") - .attr("href", createUrl("/wikitty/edit/", wikittyId)); - var iconEdit = $("<i></i>").addClass("icon-edit"); - aIconEdit.append(iconEdit); - leftDiv.append(aIconEdit); - var smallAccount = $("<small></small>"); - if (wikitty["Quotation.customer"]!=null){ - var customer = data.preloaded[wikitty["Quotation.customer"]]; - var firstName = customer.preloaded[customer.data["Employee.person"]].data["Person.firstName"]; - var lastName = customer.preloaded[customer.data["Employee.person"]].data["Person.lastName"]; - var company = customer.preloaded[customer.data["Employee.company"]].data["Company.name"]; - } - var aAccount = $("<a></a>") - .text(firstName + " " + lastName + " (" + company + ")") - .attr("href",createUrl("/wikitty/Employee/view/", wikitty["Quotation.customer"])); - smallAccount.append(aAccount); - leftDiv.append(smallAccount); - var leftP = $("<p> - </p>"); - var itemTitleSpan = $('<span></span>').addClass('salesFunnelItemTitle'); + var li = $("<li></li>").addClass("salesFunnelItem draft"); - if (wikitty["Quotation.project"]!=null) { - var aProject = $("<a/>") - .addClass("nameLink") - .attr("href" , createUrl("/wikitty/Project/view/", wikitty["Quotation.project"])) - .text(data.preloaded[wikitty["Quotation.project"]].data["Project.name"]); - } - itemTitleSpan.append(aProject); - var descriptionSmall = $('<small/>').text(wikitty["Quotation.description"]); - leftP.append(descriptionSmall); - leftP.prepend(itemTitleSpan); - leftDiv.append(leftP); + //leftDiv + var leftDiv = $("<div></div>").addClass("pull-left"); + var aIconEdit = $("<a></a>") + .attr("href", createUrl("/wikitty/edit/", wikittyId)); + var iconEdit = $("<i></i>").addClass("icon-edit"); + aIconEdit.append(iconEdit); + leftDiv.append(aIconEdit); + var smallAccount = $("<small></small>"); + if (wikitty["Quotation.customer"]!=null){ + var customer = data.preloaded[wikitty["Quotation.customer"]]; + var firstName = customer.preloaded[customer.data["Employee.person"]].data["Person.firstName"]; + var lastName = customer.preloaded[customer.data["Employee.person"]].data["Person.lastName"]; + var company = customer.preloaded[customer.data["Employee.company"]].data["Company.name"]; + } + var aAccount = $("<a></a>") + .text(firstName + " " + lastName + " (" + company + ")") + .attr("href",createUrl("/wikitty/Employee/view/", wikitty["Quotation.customer"])); + smallAccount.append(aAccount); + leftDiv.append(smallAccount); + var leftP = $("<p> - </p>"); + var itemTitleSpan = $('<span></span>').addClass('salesFunnelItemTitle'); - //button - var aSend = $('<a/>') - .attr('wikittyId', wikittyId) - .addClass("btn btn-success pull-right salesFunnelItemButton draft") - .text("Envoyer") - .click(draftToSent); + if (wikitty["Quotation.project"]!=null) { + var aProject = $("<a/>") + .addClass("nameLink") + .attr("href" , createUrl("/wikitty/Project/view/", wikitty["Quotation.project"])) + .text(data.preloaded[wikitty["Quotation.project"]].data["Project.name"]); + } + itemTitleSpan.append(aProject); + var descriptionSmall = $('<small/>').text(wikitty["Quotation.description"]); + leftP.append(descriptionSmall); + leftP.prepend(itemTitleSpan); + leftDiv.append(leftP); - var aCancelled = $('<a/>') - .attr('wikittyId', wikittyId) - .addClass("btn btn-warning pull-right salesFunnelItemButton toCancelled") - .text("Annuler") - .click(toCancelled); + //button + var aSend = $('<a/>') + .attr('wikittyId', wikittyId) + .addClass("btn btn-success pull-right salesFunnelItemButton draft") + .text("Envoyer") + .click(draftToSent); - //rightDiv - var rightDiv = $("<div>").addClass("pull-right"); - var rightP = $("<p>").addClass("salesFunnelItemTitle").text(wikitty["Quotation.amount"] +" €"); - if (wikitty["Quotation.category"] != null) { - var smallInfo = $("<small>") - .text(data.preloaded[wikitty["Quotation.category"]].data["WikittyTreeNode.name"] - + ' - ' + wikitty["Quotation.estimatedDays"] + 'j - ' + - wikitty["Quotation.conversionHope"] + "%"); - } - rightDiv.append(rightP); - rightDiv.append(smallInfo); + var aCancelled = $('<a/>') + .attr('wikittyId', wikittyId) + .addClass("btn btn-warning pull-right salesFunnelItemButton toCancelled") + .text("Annuler") + .click(toCancelled); - //clear:both - var clearBoth=$("<div style='clear:both;'/>") + //rightDiv + var rightDiv = $("<div>").addClass("pull-right"); + var rightP = $("<p>").addClass("salesFunnelItemTitle").text(wikitty["Quotation.amount"] +" €"); + if (wikitty["Quotation.category"] != null) { + var smallInfo = $("<small>") + .text(data.preloaded[wikitty["Quotation.category"]].data["WikittyTreeNode.name"] + + ' - ' + wikitty["Quotation.estimatedDays"] + 'j - ' + + wikitty["Quotation.conversionHope"] + "%"); + } + rightDiv.append(rightP); + rightDiv.append(smallInfo); - li.append(leftDiv); - li.append(aSend); - li.append(aCancelled); - li.append(rightDiv); - li.append(clearBoth); + //clear:both + var clearBoth=$("<div style='clear:both;'/>") - var drafts = $(".drafts"); - drafts.append(li); - oldQuotation.slideUp(); + li.append(leftDiv); + li.append(aSend); + li.append(aCancelled); + li.append(rightDiv); + li.append(clearBoth); - //update draftAmount and draftAmountHope - var draftAmount = parseInt($("#draftAmount").text()) + wikitty["Quotation.amount"]; - var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; - var draftAmountHope = parseInt($("#draftAmountHope").text()) + amountHope; - $("#draftAmount").text(draftAmount); - $("#draftAmountHope").text(draftAmountHope); + var drafts = $(".drafts"); + drafts.append(li); + oldQuotation.slideUp(); - //update leadAmount and leadAmountHope - var leadAmount = parseInt($("#leadAmount").text()) - wikitty["Quotation.amount"]; - var leadAmountHope = parseInt($("#leadAmountHope").text()) - amountHope; - $("#leadAmount").text(leadAmount); - $("#leadAmountHope").text(leadAmountHope); + //update draftAmount and draftAmountHope + var draftAmount = parseInt($("#draftAmount").text()) + wikitty["Quotation.amount"]; + var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; + var draftAmountHope = parseInt($("#draftAmountHope").text()) + amountHope; + $("#draftAmount").text(draftAmount); + $("#draftAmountHope").text(draftAmountHope); - allFields.val(""); + //update leadAmount and leadAmountHope + var leadAmount = parseInt($("#leadAmount").text()) - wikitty["Quotation.amount"]; + var leadAmountHope = parseInt($("#leadAmountHope").text()) - amountHope; + $("#leadAmount").text(leadAmount); + $("#leadAmountHope").text(leadAmountHope); - dialog.dialog( "close" ); + allFields.val(""); - }).fail(function(){ - //fail - //TODO JC20130212 retour utilisateur - dialog.dialog( "close" ); - }); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function() { - }, - open: function(event, ui) { - var date = new Date(); - $("#sendingDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); - } - }); + dialog.dialog( "close" ); - //Passage d'un draft -> sent - $("a.draft").click(draftToSent); + }).fail(function(){ + //fail + //TODO JC20130212 retour utilisateur + dialog.dialog( "close" ); + }); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + }, + open: function(event, ui) { + var date = new Date(); + $("#sendingDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); + } + }); - $( "#dialog-form-draftToSent" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - Ok: function() { + //Passage d'un draft -> sent + $("a.draft").click(draftToSent); - var sendingDate = $("#sendDate").val(); - var id = $("#draft-wikittyId").val(); - var oldQuotation = $(this).data('oldQuotation'); - var allFields = $([]).add($("#sendDate")).add($("#draft-wikittyId")) + $( "#dialog-form-draftToSent" ).dialog({ + autoOpen: false, + height: 300, + width: 350, + modal: true, + buttons: { + Ok: function() { - var dialog = $( this ); + var sendingDate = $("#sendDate").val(); + var id = $("#draft-wikittyId").val(); + var oldQuotation = $(this).data('oldQuotation'); + var allFields = $([]).add($("#sendDate")).add($("#draft-wikittyId")) - $.post(createUrl("/sales/funnel/json/send/", id,"?sendingDate=", sendingDate), - function(data){ - //success + var dialog = $( this ); - var wikittyId = data.meta.id; - var wikitty = data.data; + $.post(createUrl("/sales/funnel/json/send/", id,"?sendingDate=", sendingDate), + function(data){ + //success - var li = $("<li></li>").addClass("salesFunnelItem draft"); + var wikittyId = data.meta.id; + var wikitty = data.data; - //leftDiv - var leftDiv = $("<div></div>").addClass("pull-left"); - var aIconEdit = $("<a></a>") - .attr("href",createUrl("/wikitty/edit/", wikittyId)); - var iconEdit = $("<i></i>").addClass("icon-edit"); - aIconEdit.append(iconEdit); - leftDiv.append(aIconEdit); - var smallAccount = $("<small></small>"); - if (wikitty["Quotation.customer"]!=null){ - var customer = data.preloaded[wikitty["Quotation.customer"]]; - var firstName = customer.preloaded[customer.data["Employee.person"]].data["Person.firstName"]; - var lastName = customer.preloaded[customer.data["Employee.person"]].data["Person.lastName"]; - var company = customer.preloaded[customer.data["Employee.company"]].data["Company.name"]; - } - var aAccount = $("<a></a>") - .text(firstName + " " + lastName + " (" + company + ")") - .attr("href", createUrl("/wikitty/Employee/view/", wikitty["Quotation.customer"])); - smallAccount.append(aAccount); - leftDiv.append(smallAccount); - var leftP = $("<p> - </p>"); - var itemTitleSpan = $('<span></span>').addClass('salesFunnelItemTitle'); + var li = $("<li></li>").addClass("salesFunnelItem draft"); - if (wikitty["Quotation.project"]!=null) { - var aProject = $("<a/>") - .addClass("nameLink") - .attr("href" , createUrl("/wikitty/Project/view/", wikitty["Quotation.project"])) - .text(data.preloaded[wikitty["Quotation.project"]].data["Project.name"]); - } - itemTitleSpan.append(aProject); - var descriptionSmall = $('<small/>').text(wikitty["Quotation.description"]); - leftP.append(descriptionSmall); - leftP.prepend(itemTitleSpan); - leftDiv.append(leftP); + //leftDiv + var leftDiv = $("<div></div>").addClass("pull-left"); + var aIconEdit = $("<a></a>") + .attr("href",createUrl("/wikitty/edit/", wikittyId)); + var iconEdit = $("<i></i>").addClass("icon-edit"); + aIconEdit.append(iconEdit); + leftDiv.append(aIconEdit); + var smallAccount = $("<small></small>"); + if (wikitty["Quotation.customer"]!=null){ + var customer = data.preloaded[wikitty["Quotation.customer"]]; + var firstName = customer.preloaded[customer.data["Employee.person"]].data["Person.firstName"]; + var lastName = customer.preloaded[customer.data["Employee.person"]].data["Person.lastName"]; + var company = customer.preloaded[customer.data["Employee.company"]].data["Company.name"]; + } + var aAccount = $("<a></a>") + .text(firstName + " " + lastName + " (" + company + ")") + .attr("href", createUrl("/wikitty/Employee/view/", wikitty["Quotation.customer"])); + smallAccount.append(aAccount); + leftDiv.append(smallAccount); + var leftP = $("<p> - </p>"); + var itemTitleSpan = $('<span></span>').addClass('salesFunnelItemTitle'); - //button - var aAccepted = $('<a/>') - .attr('wikittyId', wikittyId) - .addClass("btn btn-success pull-right salesFunnelItemButton sent toAccepted") - .text("Accepté") - .click(sentToAccepted); - var aRejected = $('<a/>') - .attr('wikittyId', wikittyId) - .addClass("btn btn-danger pull-right salesFunnelItemButton sent toRejected") - .text("Rejeté") - .click(sentToRejected); - var aCancelled = $('<a/>') - .attr('wikittyId', wikittyId) - .addClass("btn btn-warning pull-right salesFunnelItemButton sent toCancelled") - .text("Annuler") - .click(toCancelled); + if (wikitty["Quotation.project"]!=null) { + var aProject = $("<a/>") + .addClass("nameLink") + .attr("href" , createUrl("/wikitty/Project/view/", wikitty["Quotation.project"])) + .text(data.preloaded[wikitty["Quotation.project"]].data["Project.name"]); + } + itemTitleSpan.append(aProject); + var descriptionSmall = $('<small/>').text(wikitty["Quotation.description"]); + leftP.append(descriptionSmall); + leftP.prepend(itemTitleSpan); + leftDiv.append(leftP); - //rightDiv - var rightDiv = $("<div>").addClass("pull-right"); - var rightP = $("<p>").addClass("salesFunnelItemTitle").text(wikitty["Quotation.amount"] +" €"); - if (wikitty["Quotation.category"] != null) { - var smallInfo = $("<small>") - .text(data.preloaded[wikitty["Quotation.category"]].data["WikittyTreeNode.name"] - + ' - ' + wikitty["Quotation.estimatedDays"] + 'j - ' + - wikitty["Quotation.conversionHope"] + "%"); - } - rightDiv.append(rightP); - rightDiv.append(smallInfo); + //button + var aAccepted = $('<a/>') + .attr('wikittyId', wikittyId) + .addClass("btn btn-success pull-right salesFunnelItemButton sent toAccepted") + .text("Accepté") + .click(sentToAccepted); + var aRejected = $('<a/>') + .attr('wikittyId', wikittyId) + .addClass("btn btn-danger pull-right salesFunnelItemButton sent toRejected") + .text("Rejeté") + .click(sentToRejected); + var aCancelled = $('<a/>') + .attr('wikittyId', wikittyId) + .addClass("btn btn-warning pull-right salesFunnelItemButton sent toCancelled") + .text("Annuler") + .click(toCancelled); - //clear:both - var clearBoth=$("<div style='clear:both;'/>") + //rightDiv + var rightDiv = $("<div>").addClass("pull-right"); + var rightP = $("<p>").addClass("salesFunnelItemTitle").text(wikitty["Quotation.amount"] +" €"); + if (wikitty["Quotation.category"] != null) { + var smallInfo = $("<small>") + .text(data.preloaded[wikitty["Quotation.category"]].data["WikittyTreeNode.name"] + + ' - ' + wikitty["Quotation.estimatedDays"] + 'j - ' + + wikitty["Quotation.conversionHope"] + "%"); + } + rightDiv.append(rightP); + rightDiv.append(smallInfo); - li.append(leftDiv); - li.append(aAccepted); - li.append(aRejected); - li.append(aCancelled); - li.append(rightDiv); - li.append(clearBoth); + //clear:both + var clearBoth=$("<div style='clear:both;'/>") - var sents = $(".sents"); - sents.append(li); - oldQuotation.slideUp(); + li.append(leftDiv); + li.append(aAccepted); + li.append(aRejected); + li.append(aCancelled); + li.append(rightDiv); + li.append(clearBoth); - //update draftAmount and draftAmountHope - var draftAmount = parseInt($("#draftAmount").text()) - wikitty["Quotation.amount"]; - var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; - var draftAmountHope = parseInt($("#draftAmountHope").text()) - amountHope; - $("#draftAmount").text(draftAmount); - $("#draftAmountHope").text(draftAmountHope); + var sents = $(".sents"); + sents.append(li); + oldQuotation.slideUp(); - //update sentAmount and sentAmountHope - var sentAmount = parseInt($("#sentAmount").text()) + wikitty["Quotation.amount"]; - var sentAmountHope = parseInt($("#sentAmountHope").text()) + amountHope; - $("#sentAmount").text(sentAmount); - $("#sentAmountHope").text(sentAmountHope); + //update draftAmount and draftAmountHope + var draftAmount = parseInt($("#draftAmount").text()) - wikitty["Quotation.amount"]; + var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; + var draftAmountHope = parseInt($("#draftAmountHope").text()) - amountHope; + $("#draftAmount").text(draftAmount); + $("#draftAmountHope").text(draftAmountHope); - allFields.val(""); + //update sentAmount and sentAmountHope + var sentAmount = parseInt($("#sentAmount").text()) + wikitty["Quotation.amount"]; + var sentAmountHope = parseInt($("#sentAmountHope").text()) + amountHope; + $("#sentAmount").text(sentAmount); + $("#sentAmountHope").text(sentAmountHope); - dialog.dialog( "close" ); + allFields.val(""); - }).fail(function(){ - //fail - //TODO JC20130212 retour utilisateur - dialog.dialog( "close" ); - }); + dialog.dialog( "close" ); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function() { - }, - open: function(event, ui) { - var date = new Date(); - $("#sendDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); - } - }); + }).fail(function(){ + //fail + //TODO JC20130212 retour utilisateur + dialog.dialog( "close" ); + }); - //Passage d'un sent vers accepted - $("a.toAccepted").click(sentToAccepted); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + }, + open: function(event, ui) { + var date = new Date(); + $("#sendDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); + } + }); - $( "#dialog-form-sentToAccepted" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - Ok: function() { + //Passage d'un sent vers accepted + $("a.toAccepted").click(sentToAccepted); - var acceptedDate = $("#acceptedDate").val(); - var id = $("#sent-wikittyId").val(); - var oldQuotation = $(this).data('oldQuotation'); - var allFields = $([]).add($("#acceptedDate")).add($("#sent-wikittyId")) + $( "#dialog-form-sentToAccepted" ).dialog({ + autoOpen: false, + height: 300, + width: 350, + modal: true, + buttons: { + Ok: function() { - var dialog = $( this ); + var acceptedDate = $("#acceptedDate").val(); + var id = $("#sent-wikittyId").val(); + var oldQuotation = $(this).data('oldQuotation'); + var allFields = $([]).add($("#acceptedDate")).add($("#sent-wikittyId")) - $.post(createUrl("/sales/funnel/json/accept/", id,"?acceptedDate=", acceptedDate), - function(data){ - //success - oldQuotation.slideUp(); + var dialog = $( this ); - var wikitty = data.data; + $.post(createUrl("/sales/funnel/json/accept/", id,"?acceptedDate=", acceptedDate), + function(data){ + //success + oldQuotation.slideUp(); - //update sentAmount and sentAmountHope - var sentAmount = parseInt($("#sentAmount").text()) - wikitty["Quotation.amount"]; - var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; - var sentAmountHope = parseInt($("#sentAmountHope").text()) - amountHope; - $("#sentAmount").text(sentAmount); - $("#sentAmountHope").text(sentAmountHope); + var wikitty = data.data; - allFields.val(""); + //update sentAmount and sentAmountHope + var sentAmount = parseInt($("#sentAmount").text()) - wikitty["Quotation.amount"]; + var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; + var sentAmountHope = parseInt($("#sentAmountHope").text()) - amountHope; + $("#sentAmount").text(sentAmount); + $("#sentAmountHope").text(sentAmountHope); - dialog.dialog( "close" ); + allFields.val(""); - }).fail(function(){ - //fail - //TODO JC20130212 retour utilisateur - dialog.dialog( "close" ); - }); + dialog.dialog( "close" ); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function() { - }, - open: function(event, ui) { - var date = new Date(); - $("#acceptedDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); - } - }); + }).fail(function(){ + //fail + //TODO JC20130212 retour utilisateur + dialog.dialog( "close" ); + }); - //Passage d'un sent vers rejected - $("a.toRejected").click(sentToRejected); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + }, + open: function(event, ui) { + var date = new Date(); + $("#acceptedDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); + } + }); - $( "#dialog-form-sentToRejected" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - Ok: function() { + //Passage d'un sent vers rejected + $("a.toRejected").click(sentToRejected); - var rejectedDate = $("#rejectedDate").val(); - var id = $("#rejected-wikittyId").val(); - var oldQuotation = $(this).data('oldQuotation'); - var allFields = $([]).add($("#rejectedDate")).add($("#rejected-wikittyId")) + $( "#dialog-form-sentToRejected" ).dialog({ + autoOpen: false, + height: 300, + width: 350, + modal: true, + buttons: { + Ok: function() { - var dialog = $( this ); + var rejectedDate = $("#rejectedDate").val(); + var id = $("#rejected-wikittyId").val(); + var oldQuotation = $(this).data('oldQuotation'); + var allFields = $([]).add($("#rejectedDate")).add($("#rejected-wikittyId")) - $.post(createUrl("/sales/funnel/json/reject/", id,"?rejectedDate=", rejectedDate), - function(data){ - //success - oldQuotation.slideUp(); + var dialog = $( this ); - var wikitty = data.data; + $.post(createUrl("/sales/funnel/json/reject/", id,"?rejectedDate=", rejectedDate), + function(data){ + //success + oldQuotation.slideUp(); - //update sentAmount and sentAmountHope - var sentAmount = parseInt($("#sentAmount").text()) - wikitty["Quotation.amount"]; - var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; - var sentAmountHope = parseInt($("#sentAmountHope").text()) - amountHope; - $("#sentAmount").text(sentAmount); - $("#sentAmountHope").text(sentAmountHope); + var wikitty = data.data; - allFields.val(""); + //update sentAmount and sentAmountHope + var sentAmount = parseInt($("#sentAmount").text()) - wikitty["Quotation.amount"]; + var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; + var sentAmountHope = parseInt($("#sentAmountHope").text()) - amountHope; + $("#sentAmount").text(sentAmount); + $("#sentAmountHope").text(sentAmountHope); - dialog.dialog( "close" ); + allFields.val(""); - }).fail(function(){ - //fail - //TODO JC20130212 retour utilisateur - dialog.dialog( "close" ); - }); + dialog.dialog( "close" ); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function() { - }, - open: function(event, ui) { - var date = new Date(); - $("#rejectedDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); - } - }); + }).fail(function(){ + //fail + //TODO JC20130212 retour utilisateur + dialog.dialog( "close" ); + }); - //Passage vers cancelled - $("a.toCancelled").click(toCancelled); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + }, + open: function(event, ui) { + var date = new Date(); + $("#rejectedDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); + } + }); - $( "#dialog-form-toCancelled" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - Ok: function() { + //Passage vers cancelled + $("a.toCancelled").click(toCancelled); - var cancelledDate = $("#cancelledDate").val(); - var reason = $("#cancelledReason").val(); - var id = $("#cancelled-wikittyId").val(); - var oldQuotation = $(this).data('oldQuotation'); - var allFields = $([]).add($("#cancelledDate")).add($("#cancelled-wikittyId")).add($("#cancelledReason")); + $( "#dialog-form-toCancelled" ).dialog({ + autoOpen: false, + height: 300, + width: 350, + modal: true, + buttons: { + Ok: function() { - var dialog = $( this ); + var cancelledDate = $("#cancelledDate").val(); + var reason = $("#cancelledReason").val(); + var id = $("#cancelled-wikittyId").val(); + var oldQuotation = $(this).data('oldQuotation'); + var allFields = $([]).add($("#cancelledDate")).add($("#cancelled-wikittyId")).add($("#cancelledReason")); - $.post(createUrl("/sales/funnel/json/cancel/", id,"?cancelledDate=", cancelledDate,"&reason=",reason), - function(data){ - //success - oldQuotation.slideUp(); + var dialog = $( this ); - var wikitty = data.data; + $.post(createUrl("/sales/funnel/json/cancel/", id,"?cancelledDate=", cancelledDate,"&reason=",reason), + function(data){ + //success + oldQuotation.slideUp(); - //TODO JC20130527 update amounts - //update sentAmount and sentAmountHope - //var sentAmount = parseInt($("#sentAmount").text()) - wikitty["Quotation.amount"]; - //var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; - //var sentAmountHope = parseInt($("#sentAmountHope").text()) - amountHope; - //$("#sentAmount").text(sentAmount); - //$("#sentAmountHope").text(sentAmountHope); + var wikitty = data.data; - allFields.val(""); - dialog.dialog( "close" ); + //TODO JC20130527 update amounts + //update sentAmount and sentAmountHope + //var sentAmount = parseInt($("#sentAmount").text()) - wikitty["Quotation.amount"]; + //var amountHope = wikitty["Quotation.amount"]*wikitty["Quotation.conversionHope"]/100; + //var sentAmountHope = parseInt($("#sentAmountHope").text()) - amountHope; + //$("#sentAmount").text(sentAmount); + //$("#sentAmountHope").text(sentAmountHope); - }).fail(function(){ - //fail - //TODO JC20130212 retour utilisateur - dialog.dialog( "close" ); - }); + allFields.val(""); + dialog.dialog( "close" ); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function() { - }, - open: function(event, ui) { - var date = new Date(); - $("#cancelledDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); - } - }); + }).fail(function(){ + //fail + //TODO JC20130212 retour utilisateur + dialog.dialog( "close" ); + }); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + }, + open: function(event, ui) { + var date = new Date(); + $("#cancelledDate").val(date.getDate() + "/" + (date.getMonth()+1)+"/"+date.getFullYear()); + } + }); + // ******************************************************************** // * PROJECT DASHBOARD * // ******************************************************************** @@ -724,87 +724,82 @@ function displayFields() { var id = $(this).attr('wikittyId'); - + $("#upgradeFields-" + id).slideUp(); if(this.selectedIndex == 0) { $("#upgradeFields-" + id).text(""); } else { - $("#upgradeFields-" + id ).text("Loading fields for " + this.item(this.selectedIndex).label + "..."); + var extensionName = this.item(this.selectedIndex).label; - $.get(createUrl("/project/json/getExtension/", extensionName, "/" + $(this).attr('wikittyId')), function(data){ - //success - var $jData = $(data); - - - $("#upgradeFields-" + id).html($jData[0].outerHTML);//.innerHTML); - initFields(); + //success + var $jData = $(data); + + $("#upgradeFields-" + id).html($jData[0].outerHTML);//.innerHTML); + initFields(); + $("#upgradeFields-" + id).slideDown(); + }); } } $("a.upgrade").click(upgradeQuotation); $("select.extBox").change(displayFields); + $("#project_hidden").change(function() { $("#projectSearch").submit(); }); - function initgantt() { - - var id = $(this).attr('wikittyId'); - - - "use strict"; - - - - $(".gantt-"+id).gantt({ - source: ganttData[id]['src'], - dateStart: ganttData[id]['startDate'], - dateEnd:ganttData[id]['endDate'], - extDate : { - "Draft sent" : ganttData[id]['sendingDate'], - "Sent" : ganttData[id]['postedDate'], - "Accepted" : ganttData[id]['acceptedDate'], - "Started" : ganttData[id]['startedDate'], - "Delivered" : ganttData[id]['deliveryDate'], - "RSV started" : ganttData[id]['rsvStart'], - "Warranty Started" : ganttData[id]['warrantyStart'], - "Closed" : ganttData[id]['closedDate'], - "Rejected" : ganttData[id]['rejectedDate'], - "Cancelled" : ganttData[id]['cancelledDate'] - }, - draftSent:ganttData[id]['draftSent'], - navigate: "scroll", - scale: "days", - maxScale: "months", - minScale: "days", - itemsPerPage: 10, - onItemClick: function(data) { - alert("Item clicked - show some details"); - }, - onAddClick: function(dt, rowId) { - alert("Empty space clicked - add an item!"); - }, - onRender: function() { - if (window.console && typeof console.log === "function") { - console.log("chart rendered"); + $("#quotationFilter").change(function() { + if($("#project_hidden").val() != "") + $("#projectSearch").submit(); + }); + function initgantt(id) { + "use strict"; + $.get(createUrl("/project/json/getGanttInfo/",id), + function(ret){ + var data = ret['data']; + console.log(data); + if(data['source'].length != 0) { + $(".gantt-"+id).gantt({ + source: data['source'], + dateStart: data['dateStart'], + dateEnd:data['dateEnd'], + extDate : data['extDate'], + navigate: "scroll", + scale: "days", + maxScale: "months", + minScale: "days", + itemsPerPage: 10, + onItemClick: function(data) { + alert("Item clicked - show some details"); + }, + onAddClick: function(dt, rowId) { + alert("Empty space clicked - add an item!"); + }, + onRender: function() { + if (window.console && typeof console.log === "function") { + console.log("chart rendered"); + + } } - } - }); - - - - - prettyPrint(); - } + }); + } + }); - $("a.ganttinit").click(initgantt); - + } + for(var i = 0; i < $('.gantt').length; i++) { + var div = $('.gantt')[i]; + console.log(div); + initgantt(div.attributes.wikittyid.nodeValue); + } + + + }); \ No newline at end of file Modified: trunk/chorem-webmotion/src/main/webapp/js/jquery.fn.gantt.js =================================================================== --- trunk/chorem-webmotion/src/main/webapp/js/jquery.fn.gantt.js 2013-06-26 09:30:51 UTC (rev 347) +++ trunk/chorem-webmotion/src/main/webapp/js/jquery.fn.gantt.js 2013-06-27 14:07:10 UTC (rev 348) @@ -1027,24 +1027,88 @@ var cd = Date.parse(new Date()); cd = (Math.floor(cd / 36400000) * 36400000); $(element).find(':findweek("' + cd + '")').removeClass('wd').addClass('today'); + + var str = ""; + + var start = $(element).find(':findweek("' + Date.parse(tools.dateDeserialize(settings.dateStart)) + '")'); + if(start.attr('over') != null) + str = start.attr("over") + "<br />"; + str += "Project start"; + start.removeClass('wd').addClass('begin').attr('over',str); + str=""; + var end = $(element).find(':findweek("' + Date.parse(tools.dateDeserialize(settings.dateEnd)) + '")'); + if(end.attr('over') != null) + str = end.attr("over") + "<br />"; + str += "Project end"; + end.removeClass('wd').addClass('end').attr('over',str); + + for(var key in settings.extDate) { + if(settings.extDate[key] != undefined) { + str=""; + var event = $(element).find(':findweek("' + Date.parse(tools.dateDeserialize(settings.extDate[key])) + '")'); + if(event.attr('over') != null) + str = event.attr("over") + "<br />"; + str += key; + event.removeClass('wd').addClass('event').attr('over',str); + } + } break; case "months": $(element).find(':findmonth("' + new Date().getTime() + '")').removeClass('wd').addClass('today'); + + var str = ""; + + var start = $(element).find(':findmonth("' + Date.parse(tools.dateDeserialize(settings.dateStart)) + '")'); + if(start.attr('over') != null) + str = start.attr("over") + "<br />"; + str += "Project start"; + start.removeClass('wd').addClass('begin').attr('over',str); + str=""; + var end = $(element).find(':findmonth("' + Date.parse(tools.dateDeserialize(settings.dateEnd)) + '")'); + if(end.attr('over') != null) + str = end.attr("over") + "<br />"; + str += "Project end"; + end.removeClass('wd').addClass('end').attr('over',str); + + for(var key in settings.extDate) { + + if(settings.extDate[key] != undefined) { + str=""; + var event = $(element).find(':findmonth("' + Date.parse(tools.dateDeserialize(settings.extDate[key])) + '")'); + if(event.attr('over') != null) + str = event.attr("over") + "<br />"; + str += key; + event.removeClass('wd').addClass('event').attr('over',str); + } + } break; default: var cd = Date.parse(new Date()); cd = (Math.floor(cd / 36400000) * 36400000); $(element).find(':findday("' + cd + '")').removeClass('wd').addClass('today'); - var bd = Date.parse(tools.dateDeserialize(settings.dateStart)); - //bd = (Math.floor(bd / 36400000) * 36400000); - $(element).find(':findday("' + bd + '")').removeClass('wd').addClass('begin').attr('over',"Project start"); + var str = ""; - $(element).find(':findday("' + Date.parse(tools.dateDeserialize(settings.dateEnd)) + '")').removeClass('wd').addClass('end').attr('over',"Project end"); - console.log(settings.extDate); + var start = $(element).find(':findday("' + Date.parse(tools.dateDeserialize(settings.dateStart)) + '")'); + if(start.attr('over') != null) + str = start.attr("over") + "<br />"; + str += "Project start"; + start.removeClass('wd').addClass('begin').attr('over',str); + str=""; + var end = $(element).find(':findday("' + Date.parse(tools.dateDeserialize(settings.dateEnd)) + '")'); + if(end.attr('over') != null) + str = end.attr("over") + "<br />"; + str += "Project end"; + end.removeClass('wd').addClass('end').attr('over',str); + for(var key in settings.extDate) { - console.log("passe"); - if(settings.extDate[key] != undefined) - $(element).find(':findday("' + Date.parse(tools.dateDeserialize(settings.extDate[key])) + '")').removeClass('wd').addClass('event').attr('over',key); + if(settings.extDate[key] != undefined) { + str=""; + var event = $(element).find(':findday("' + Date.parse(tools.dateDeserialize(settings.extDate[key])) + '")'); + if(event.attr('over') != null) + str = event.attr("over") + "<br />"; + str += key; + event.removeClass('wd').addClass('event').attr('over',str); + } } break; }