Exemple #1
0
    public static string add_SVG_gRelationsFromBasketToAcceptMembership(backoffice.admin_shop shop)
    {
        StringBuilder s = new StringBuilder();

        backoffice.shop_event rightLooper = shop.firstShopEvent;
        while (rightLooper != null)
        {
            // a) We can have more than one terminal, so we have to search to the end ...
            // b) Membership can have been accepted earlier so we start even before the basket
            backoffice.shop_event anchorLooper = shop.firstShopEvent;
            while (anchorLooper != null)
            {
                if (anchorLooper != rightLooper) // Don't relate to yourself ...
                {
                    if (anchorLooper.sToken == rightLooper.sToken)
                    {
                        if ((rightLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_CONFIRMED || rightLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_NOT_CONFIRMED) &&
                            anchorLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.C_MEMBERSHIP_ACCEPTED)
                        // && rightLooper.higherPointer == null)
                        {
                            rightLooper.higherPointer = anchorLooper;
                            s.Append(
                                "<line " +
                                " x1=" + rightLooper.xCenter.ToString() + " y1=" + rightLooper.yCenter +
                                " x2=" + anchorLooper.xCenter.ToString() + " y2=" + anchorLooper.yCenter.ToString() + " style='stroke:rgb(180,180,180);stroke-width:2' />");
                        }
                    }
                }
                anchorLooper = anchorLooper.Next;
            }

            rightLooper = rightLooper.Next;
        }
        return(s.ToString());
    }
Exemple #2
0
    public static string add_SVG_gRelationsFromCardInsertToBasket(backoffice.admin_shop shop)
    {
        StringBuilder s = new StringBuilder();

        backoffice.shop_event rightLooper = shop.firstShopEvent;
        while (rightLooper != null)
        {
            /*
             * A_PHONE_ENROLLED,
             *  B_BASKET_NOT_CONFIRMED,
             *  B_BASKET_CONFIRMED,
             * C_MEMBERSHIP_ACCEPTED,
             *
             * A_PHONE_ALREADY_MEMBER, Can be a 2 or a 1
             *  B_BASKET_NOT_CONFIRMED,
             *  B_BASKET_CONFIRMED,
             * C_MEMBERSHIP_ACCEPTED,
             *
             * A_PHONE_SKIPPED,
             *  END
             *
             * B_BASKET_CONFIRMED,
             * C_MEMBERSHIP_ACCEPTED,
             *
             * B_BASKET_NOT_CONFIRMED,
             * C_MEMBERSHIP_ACCEPTED,
             *
             * C_MEMBERSHIP_ACCEPTED,
             *  END
             */

            // We can have more than one terminal, so we have to search to the end ...

            backoffice.shop_event anchorLooper = rightLooper.Next;
            while (anchorLooper != null)
            {
                if (rightLooper.sToken.IndexOf(anchorLooper.sToken) >= 0)
                {
                    if ((rightLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_PHONE_ENROLLED || rightLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_CONSUMER_EXISTS || rightLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_CONSUMER_EXISTS_AND_IS_MEMBER || rightLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_PHONE_SKIPPED) &&
                        (
                            anchorLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_CONFIRMED ||
                            anchorLooper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_NOT_CONFIRMED) &&
                        rightLooper.higherPointer == null)
                    {
                        rightLooper.higherPointer = anchorLooper;
                        s.Append(
                            "<line " +
                            " x1=" + rightLooper.xCenter.ToString() + " y1=" + rightLooper.yCenter +
                            " x2=" + anchorLooper.xCenter.ToString() + " y2=" + anchorLooper.yCenter.ToString() + " style='stroke:rgb(255,255,255);stroke-width:1' />");
                        break;
                    }
                }
                anchorLooper = anchorLooper.Next;
            }

            rightLooper = rightLooper.Next;
        }
        return(s.ToString());
    }
Exemple #3
0
    public static string GET_TIMELINE_PART(Global global, List <backoffice.admin_shop> shopList, DateTime startFromTimestamp, int iNofSlices)
    {
        int TOTAL_WIDTH = 1000;

        bool bAllShops = false;

        StringBuilder s = new StringBuilder();


        s.Append("<div class=live_timeline>");

        s.Append("<table cellpadding=0 cellspacing=0");

        s.Append("<tr>");

        s.Append("<td valign=top id=visible_time onclick=shop_live_date_clicked() class=live_timeline_heading>");
        if (global.bRunningLive)
        {
            s.Append(getHourMinuteSecond(DateTime.Now));
        }
        else
        {
            s.Append(getDateMonthYearNorwegianPretty(startFromTimestamp));
        }
        s.Append("</td>");

        s.Append("<td>");
        s.Append(GET_TIMELINE_HEADING(global, TOTAL_WIDTH, startFromTimestamp, iNofSlices));
        s.Append("</td>");

        s.Append("<td valign=top>");
        s.Append("<div class=live_grand_total >");
        s.Append("grand_total_to_be_replaced");
        s.Append("</div>");
        s.Append("</td>");

        s.Append("<td valign=top>");
        s.Append("<div class=live_grand_total >");
        s.Append("grand_total_gold_to_be_replaced");
        s.Append("</div>");

        s.Append("</td>");
        s.Append("</tr>");


        int wBasket = 6; int hBasket = 6;
        int rCircle = 4;

        int w = TOTAL_WIDTH;
        int h = 50;

        if (bAllShops)
        {
            h = 500;
        }

        int iNofNewMembersGrandTotal  = 0;
        int iGoldMemberReturnedGlobal = 0;


        if (bAllShops)
        {
            s.Append("<tr>");
            s.Append("<td>");

            s.Append("<div id='shop_timeline_all_shops' class=live_shop>");
            s.Append("Alle butikker");
            s.Append("</div>");

            s.Append("</td>");

            // s.Append("<td valign=top colspan=" + iNofSlices.ToString() + ">");
            s.Append("<td valign=top >");


            string sShopClass = " class=live_graph_shop_timeline ";

            if (bAllShops)
            {
                sShopClass = " class=live_graph_all_shops_timeline ";
            }

            s.Append("<div " + sShopClass + " >");


            s.Append("<svg xmlns='http://www.w3.org/2000/svg' version='1.1' ");
            s.Append("width='" + w.ToString() + "' height='" + h.ToString() + "' > ");
        }


        foreach (backoffice.admin_shop shop in shopList)
        {
            if (bAllShops == false)
            {
                s.Append("<tr>");
                s.Append("<td>");

                s.Append("<div id='shop_timeline_" + shop.iId.ToString() + "' class=live_shop>");
                s.Append(shop.sName);
                s.Append("</div>");

                s.Append("</td>");

                // s.Append("<td valign=top colspan=" + iNofSlices.ToString() + ">");
                s.Append("<td valign=top >");


                string sShopClass = " class=live_graph_shop_timeline ";

                if (bAllShops)
                {
                    sShopClass = " class=live_graph_all_shops_timeline ";
                }

                s.Append("<div " + sShopClass + " >");


                s.Append("<svg xmlns='http://www.w3.org/2000/svg' version='1.1' ");
                s.Append("width='" + w.ToString() + "' height='" + h.ToString() + "' > ");
            }
            StringBuilder sShopEvents = new StringBuilder();

            int iNofNewMembers           = 0;
            int iGoldMemberReturned      = 0;
            backoffice.shop_event looper = shop.firstShopEvent;
            while (looper != null)
            {
                // 16 sept
                // Merkelig feil på testserver gjør at man må legge til en time ...
                bool bFixTestServerProblem = false;

                if (bFixTestServerProblem)
                {
                    if (looper.shopEventType.ToString().StartsWith("A"))
                    {
                        looper.timestamp = looper.timestamp.AddHours(1);
                    }
                }

                int xFromTime    = GET_X_START_FROM_TIME(global, TOTAL_WIDTH, startFromTimestamp, looper.timestamp, iNofSlices);
                int startBasketY = ((h / 2) - hBasket / 2);

                int startBasketX = ((xFromTime) - wBasket / 2);

                int level_2 = (-(int)(double)(h * 0.3));
                int level_1 = 0;
                int level_0 = (int)(double)(h * 0.3);

                string sFillColor = "rgb(128,128,128)";

                looper.xCenter = xFromTime;

                // string sHourMinuteSecond = zero_2(looper.timestamp.Hour.ToString()) + ":" + zero_2(looper.timestamp.Minute.ToString()) + ":" + zero_2(looper.timestamp.Second.ToString());
                string sHourMinuteSecond = getHourMinuteSecond(looper.timestamp);

                string sOnClick     = "";
                string sSmallCircle = "";

                if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.C_MEMBERSHIP_ACCEPTED)
                {
                    sOnClick       = " onclick=shop_live_accepted_membership_event('" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_2 + (h / 2);
                    // sFillColor = "rgb(0,255,0)";
                    sFillColor   = "rgb(255,255,255)";
                    sSmallCircle = "<circle cx='" + xFromTime + "' cy='" + (looper.yCenter).ToString() + "' r='" + (2).ToString() + "' fill='rgb(255,255,255)' " +
                                   sOnClick +
                                   " /> ";
                    ++iNofNewMembers;
                    ++iNofNewMembersGrandTotal;
                }
                else if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_CONFIRMED)
                {
                    sOnClick       = " onclick=shop_live_basket_event('" + looper.sBasketRowId + "','" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_1 + (h / 2);
                    sFillColor     = "rgb(0,255,0)";
                    if (!isBasketModified(looper.sBasket_b))
                    {
                        sFillColor = "rgb(255,0,0)";                                      // No discount
                    }
                    if (!isErrorBasket(looper.sBasket_b))
                    {
                        looper.bErrorBasket = true;
                    }
                }
                else if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_NOT_CONFIRMED)
                {
                    sOnClick       = " onclick=shop_live_basket_event('" + looper.sBasketRowId + "','" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_1 + (h / 2);
                    sFillColor     = "rgb(0,255,0)";
                    if (!isBasketModified(looper.sBasket_b))
                    {
                        sFillColor = "rgb(255,0,0)";                                      // No discount
                    }
                    if (!isErrorBasket(looper.sBasket_b))
                    {
                        looper.bErrorBasket = true;
                    }
                }
                else if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_PHONE_ENROLLED)
                {
                    sOnClick       = " onclick=shop_live_card_inserted_event('" + looper.sBaxId + "','" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_0 + (h / 2);
                    sFillColor     = "rgb(0,255,0)";
                }
                else if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_PHONE_SKIPPED)
                {
                    sOnClick       = " onclick=shop_live_card_inserted_event('" + looper.sBaxId + "','" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_0 + (h / 2);
                    sFillColor     = "rgb(255,0,0)";
                }
                else if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_CONSUMER_EXISTS)
                {
                    sOnClick       = " onclick=shop_live_card_inserted_event('" + looper.sBaxId + "','" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_0 + (h / 2);
                    sFillColor     = "yellow";
                    if (looper.bAdditionalCard)
                    {
                        sSmallCircle = "<circle cx='" + xFromTime + "' cy='" + (looper.yCenter).ToString() + "' r='" + (2).ToString() + "' fill='purple' " +
                                       sOnClick +
                                       " /> ";
                    }
                }
                else if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.A_CONSUMER_EXISTS_AND_IS_MEMBER)
                {
                    sOnClick       = " onclick=shop_live_card_inserted_event('" + looper.sBaxId + "','" + looper.sToken + "','" + looper.shopEventType.ToString() + "','" + sHourMinuteSecond + "') ";
                    looper.yCenter = level_0 + (h / 2);

                    sFillColor = "rgb(255,255,255)";
                    ++iGoldMemberReturned;
                    ++iGoldMemberReturnedGlobal;
                }



                sShopEvents.Append(
                    "<circle cx='" + xFromTime + "' cy='" + (looper.yCenter).ToString() + "' r='" + (rCircle).ToString() + "' fill='" + sFillColor + "' " +
                    sOnClick +
                    " /> ");

                if (sSmallCircle != "")
                {
                    sShopEvents.Append(sSmallCircle);
                }

                if (looper.shopEventType == backoffice.SHOP_EVENT_TYPE.B_BASKET_NOT_CONFIRMED)
                {
                    sShopEvents.Append("<line " +
                                       " x1=" + (xFromTime - rCircle).ToString() + " y1=" + looper.yCenter.ToString() +
                                       " x2=" + (xFromTime + rCircle).ToString() + " y2=" + looper.yCenter.ToString() + " style='stroke:rgb(0,0,0);stroke-width:1' " +
                                       sOnClick +
                                       " />");
                }

                if (looper.bErrorBasket)
                {
                    sShopEvents.Append("<line " +
                                       " x1=" + (xFromTime).ToString() + " y1=" + (looper.yCenter - rCircle).ToString() +
                                       " x2=" + (xFromTime).ToString() + " y2=" + (looper.yCenter + rCircle).ToString() + " style='stroke:rgb(0,0,0);stroke-width:1' " +
                                       sOnClick +
                                       " />");
                }

                looper = looper.Next;
            }

            // Before closing the shop, we need to add all lines ...
            // Den vi skal peke på ligger lenger frem i tid ... det er bare å lete fremover til første match.

            s.Append(add_SVG_gRelationsFromCardInsertToBasket(shop));

            s.Append(add_SVG_gRelationsFromBasketToAcceptMembership(shop));

            s.Append(sShopEvents);


            if (bAllShops == false)
            {
                s.Append("</svg>");

                s.Append("</div>");
                s.Append("</td>");

                s.Append("<td class=live_timeline_sum >");

                // 10 juli
                if (iNofNewMembers > 0)
                {
                    s.Append(iNofNewMembers.ToString());
                }

                s.Append("</td>");

                s.Append("<td class=live_timeline_sum >");

                if (iGoldMemberReturned > 0)
                {
                    s.Append(iGoldMemberReturned.ToString());
                }

                s.Append("</td>");

                s.Append("</tr>");
            }
        }

        if (bAllShops)
        {
            s.Append("</svg>");

            s.Append("</div>");
            s.Append("</td>");

            s.Append("<td class=live_timeline_sum >");

            // 10 juli
            // if (iNofNewMembers > 0)
            //    s.Append(iNofNewMembers.ToString());

            s.Append("</td>");

            s.Append("<td class=live_timeline_sum >");

            // if (iGoldMemberReturned > 0)
            //    s.Append(iGoldMemberReturned.ToString());

            s.Append("</td>");

            s.Append("</tr>");
        }



        s.Append("</table>");

        s.Append("</div>");

        string sTotalText = (s.ToString().Replace("grand_total_to_be_replaced", iNofNewMembersGrandTotal.ToString()));

        sTotalText = (sTotalText.Replace("grand_total_gold_to_be_replaced", iGoldMemberReturnedGlobal.ToString()));


        return(sTotalText);
    }