141217_KFormLib.php 158 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202
<?php namespace App\Jobs;

use Storage;
use Auth;
use Input;
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use Log;
use DB;
$dashboarduser=Auth::user();
use App\Models\SupervisonComments;

class KFormLib
{
	private $themehome='';
	private $storagehome='';
	private $varid='';
	private $edituser='';
	public $gthis='';//TODO only set directly from empbulkupload
	private $fdirtytxt='';
	private $isuser=false;
	private $recruitdata='';
	private $oldbkrec='';
	private $bkvarid='';
	private $emprecordScripts='';
	private $HRExclusiveClients='';
	public $FormSelectVals=array();
	
	private $objcache=array();

	public $HRFiledsStr="";
	public $HRFieldNames=array();
	public $HRFileFieldsStr="";
	public $HRDateFilds="";
	public $HRDropFilds="";
	public $HRForms=array();

	public function __construct($formstr)
	{
		$fields=explode(",",$formstr);
		foreach($fields as $field)
		{
			$parts=explode(":",$field);
			if(sizeof($parts)>=3)
			{
				$this->HRFiledsStr.=$parts[0].",";
				$this->HRFieldNames[$parts[0]]=$parts[2];

				if($parts[1]=="F")$this->HRFileFieldsStr.=$parts[0].",";
				else if($parts[1]=="D")$this->HRDateFilds.=$parts[0].",";
				else if($parts[1]=="S"||$parts[1]=="M")
				{
					$this->HRDropFilds.=$parts[0].",";
					if(isset($parts[11])){$this->FormSelectVals[$parts[0]]=$parts[11];}
					else {$this->FormSelectVals[$parts[0]]="";}
				}

				$this->HRForms[$parts[3]][$parts[4]][]=array($parts[5],$parts[6],$parts[7],$parts[8],$parts[9],$parts[0],$parts[1],$parts[2],$parts[10]);
			}
		}
		
		$this->themehome=url("userfiles/templates/hrms");//TODO
		$this->storagehome=storage_path('app/templates/hrms');
	}

	public function data($config)
	{
		$this->varid=$this->getConfig('varid',$config,'');
		$this->edituser=$this->getConfig('edituser',$config,'');
		$this->gthis=$this->getConfig('gthis',$config,array());
		$this->fdirtytxt=$this->getConfig('fdirtytxt',$config,'');
		$this->isuser=$this->getConfig('isuser',$config,false);
		$this->recruitdata=$this->getConfig('recruitdata',$config,'');
		$this->oldbkrec=$this->getConfig('oldbkrec',$config,'');
		$this->bkvarid=$this->getConfig('bkvarid',$config,'');
		$this->emprecordScripts=$this->getConfig('emprecordScripts',$config,'');
		$this->HRExclusiveClients=$this->getConfig('HRExclusiveClients',$config,'');
		
		$updatetime=time();
		$this->recruitdata['modifylog'][$updatetime]=$this->gthis->GetUserName()."::";
		$this->recruitdata['modifylog']["updated"]=$updatetime;
	}
	function getConfig($str,$config,$default=false)
	{
		if(isset($config[$str]))return $config[$str];
		return $default;
	}

	function recruitFileLink($filename)
	{
		$themehome=$this->themehome;
		$varid=$this->varid;
		$edituser=$this->edituser;
		
		$fpath="$themehome/recruits/$varid/$filename";
		$fpathT="$themehome/thumbs/$varid/$filename.gif";
		if($filename!=""){$filename="<img src='$themehome/images/circle_down.png'>";if($edituser)$maillnk="<img src='$themehome/images/mail.gif'>";}
		return "<a href=# onclick=\"mailFileDialog('$fpath');return false;\" class='tooltip tooltip1' title='Send this file as Mail'>$maillnk</a>&nbsp;&nbsp;
		<a title='<img src=$fpathT width=400px>' class='tooltip tooltip1' href='$fpath' target=_BLANK><b>$filename</b></a>";
	}
	function fillSelect($selId,$selvals=array())
	{
		$rdata="";
		if($selId=='client'&&Auth::check())
		{
			if($this->gthis=='')$this->gthis=new KHRMSLib();
			$this->FormSelectVals[$selId]=implode("~",$this->gthis->clientsReadAccess());
		}

		if(isset($this->FormSelectVals[$selId]))
		{
			$values=explode("~",$this->FormSelectVals[$selId]);sort($values);
			foreach($values as $value)
			{
				$value=trim($value);
				if($value!="")
				{
					$tsel='';if(!empty($selvals)&&in_array($value,$selvals))$tsel='selected=selected';
					
					$rdata.="<option value='$value' $tsel>$value</option>";
				}
			}
			
			if(!empty($selvals))foreach($selvals as $selval)
			{
				if(!in_array($selval,$values))
				{
					$rdata.="<option value='$selval' selected=selected>$selval</option>";
				}
			}
		}
		return $rdata;
	}
	function makeSelect($id)
	{
		$fdirty=$this->recruitdata["dirty"];
		$dataarr=$this->recruitdata["peopledata"];
		$gthis=$this->gthis;
		$edituser=$this->edituser;
		$fdirtytxt=$this->fdirtytxt;
		$isuser=$this->isuser;
		
		$selarr=array();
		if($dataarr[$id]!='')$selarr[]=$dataarr[$id];
		$list=$this->fillSelect($id,$selarr);
		$list="<option value=''>&nbsp;</option>".$list;

		$data="<p style='clear:both'>
		<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
		<select id='$id' name='$id' class='form_hrm_select select2multi' style='width:50%'>$list</select>
		<span class=field_desc></span><span class=validate_success></span>
		<span class=validate_error>".((isset($fdirty[$id]))?$fdirtytxt:'')."</span>
	</p>";

	if(!$isuser||!$edituser)
	{
		$data="<p style='clear:both'>
		<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
		<b>$dataarr[$id]</b><input type=hidden id=$id value='$dataarr[$id]'>
		<span class=field_desc></span><span class=validate_success></span>
		<span class=validate_error>".((isset($fdirty[$id]))?$fdirtytxt:'')."</span>
	</p>";
}

return $data;
}
function makeMultiSelect($id,$helptxt)
{

}
function makeTextBox($id,$size,$type="text")
{
	$fdirty=$this->recruitdata["dirty"];
	$dataarr=$this->recruitdata["peopledata"];
	$gthis=$this->gthis;
	$edituser=$this->edituser;
	$fdirtytxt=$this->fdirtytxt;
	$isuser=$this->isuser;
	$varid=$this->varid;

	if(strstr($this->HRDateFilds,$id)&&!$gthis->IsAdmin()){$ro="";$formatstr='DD.MM.YYYY';}

	if($type=="text")$size.=" capText";
	if($id=='emailid')$maillnk=" <a href='mailto:$dataarr[$id]'>Mail</a> ";

	if($gthis->IsAdmin()&&$fdirty[$id]&&strstr($gthis->HRCoreVars["RequiredApproval"],$id))$approvaltxt="<input type=button class='btn btn-green' value='Approve' onclick='approveFData(\"$id\",\"$varid\");return false;'>";


	$data="<p style='clear:both'>
	<label class=label-small_new  style='width:25%;' title=$formatstr>".$this->HRFieldNames[$id].": </label>
	<input ".($type=="file"?" style='display:inline-block' size=9":"class='$size'")." id='$id' name='$id' type='$type' value='$dataarr[$id]' $ro />
	$maillnk<span class=field_desc id='fd$id'>".(($type=="file")?$this->recruitFileLink($dataarr[$id]):'')."</span>
	<span class=validate_success></span><span class=validate_error>".((isset($fdirty[$id]))?$fdirtytxt:'')." $approvaltxt</span>
</p>";
if(!$isuser||!$edituser)
{
	$data="<p style='clear:both'>
	<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
	<b>$dataarr[$id]</b>
	$maillnk<span class=field_desc id='fd$id'>".(($type=="file")?$this->recruitFileLink($dataarr[$id]):'')."</span>
	<span class=validate_success></span><span class=validate_error>".((isset($fdirty[$id]))?$fdirtytxt:'')."</span>
</p>";
}

return $data;
}


//Changes Done On 10-Sept-16 for removing Required By Manish
function makeLabelText($id,$size,$type="text")
{
	$fdirty=$this->recruitdata["dirty"];
	$dataarr=$this->recruitdata["peopledata"];
	$gthis=$this->gthis;
	$fdirtytxt=$this->fdirtytxt;

	if(strstr($this->HRDateFilds,$id)){$ro="readonly=readonly";$formatstr='DD.MM.YYYY';}

	if($id=="ucic_id"){
		$data="<p style='clear:both;background-color:#e6e5ef;'>
	<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
	<b>$dataarr[$id]</b>
	<span class=field_desc id='fd$id'>".(($type=="file")?$this->recruitFileLink($dataarr[$id]):'')."</span>
	<span class=validate_success></span><span class=validate_error></span>
</p>";

	}else{
		$data="<p style='clear:both'>
	<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
	<b>$dataarr[$id]</b>
	<span class=field_desc id='fd$id'>".(($type=="file")?$this->recruitFileLink($dataarr[$id]):'')."</span>
	<span class=validate_success></span><span class=validate_error></span>
</p>";
	}

	/*$data="<p style='clear:both'>
	<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
	<b>$dataarr[$id]</b>
	<span class=field_desc id='fd$id'>".(($type=="file")?$this->recruitFileLink($dataarr[$id]):'')."</span>
	<span class=validate_success></span><span class=validate_error></span>
</p>";*/

return $data;
}
function makeThumbImg($id)
{
	$themehome=$this->themehome;
	$dataarr=$this->recruitdata["peopledata"];
	$varid=$this->varid;

	$fpath="$themehome/images/default.jpg";
	if(file_exists($this->storagehome."/thumbs/$varid/".$dataarr[$id].".gif"))$fpath="$themehome/thumbs/$varid/".$dataarr[$id].".gif";

	$data="<p style='clear:both'>
	<label class=label-small_new style='width:25%'></label>
	<img src='$fpath' height=100px class='image_new'>
</p>";

return $data;
}
function makeTextArea($id)
{
	$fdirty=$this->recruitdata["dirty"];
	$dataarr=$this->recruitdata["peopledata"];
	$gthis=$this->gthis;
	$edituser=$this->edituser;
	$fdirtytxt=$this->fdirtytxt;
	$isuser=$this->isuser;

	$data="
	<p style='clear:both'>
		<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
		<textarea class='form_new form_new_amend' style='height:70px' id='$id' name='$id' class=capText>$dataarr[$id]</textarea>
		<span class=field_desc id='fd$id'></span>
		<span class=validate_success></span><span class=validate_error>".((isset($fdirty[$id]))?'':'')."</span>
	</p>";
	if(!$isuser||!$edituser)
	{
		$data="
		<p style='clear:both'>
			<label class=label-small_new  style='width:25%'>".$this->HRFieldNames[$id].": </label>
			<b>$dataarr[$id]</b>
			<span class=field_desc id='fd$id'></span><span class=validate_success></span>
			<span class=validate_error>".((isset($fdirty[$id]))?$fdirtytxt:'')."</span>
		</p>";
	}
	return $data;
}

function HRTemplateString($str,$fieldsstr)
{
	$ppldata=$this->recruitdata["peopledata"];
	$gthis=$this->gthis;


	if(!isset($this->objcache["ownerrmlist"]))$this->objcache["ownerrmlist"]=$gthis->getUserListforClient($ppldata['client']);
	if(!isset($this->objcache["recruitmentrmlist"]))$this->objcache["recruitmentrmlist"]=$gthis->getRecruitmentListforClient($ppldata['client']);
	if(!isset($this->objcache["acctrmlist_600"]))$this->objcache["acctrmlist_600"]=$gthis->getUserListforClientAcct($ppldata['client']);
	if(!isset($this->objcache["bdmlist_600"]))$this->objcache["bdmlist_600"]=$gthis->getUserListforClientBDM($ppldata['client']);

	if(!isset($this->objcache["ownerrmlist_M"]))$this->objcache["ownerrmlist_M"]=$gthis->getManagerUsers($this->objcache["ownerrmlist"]);
	if(!isset($this->objcache["recruitmentrmlist_600"]))$this->objcache["ownerrmlist_M"]=$gthis->getManagerUsers($this->objcache["recruitmentrmlist"]);

	$str=str_replace("{{ownerrmlist}}",$this->objcache["ownerrmlist"],$str);
	$str=str_replace("{{ownerrmlist_M}}",$this->objcache["ownerrmlist"]."/".$this->objcache["ownerrmlist_M"],$str);
	$str=str_replace("{{recruitmentrmlist}}",$this->objcache["recruitmentrmlist"],$str);
	$str=str_replace("{{acctrmlist}}",$this->objcache["acctrmlist_600"],$str);

	if($this->edituser==1)
	{
		$str=str_replace("{{recruitmentrmlist_600}}","RecruitmentRM- ".$this->objcache["recruitmentrmlist"]."/".$this->objcache["recruitmentrmlist_600"],$str);
		$str=str_replace("{{acctrmlist_600}}","Accounts- ".$this->objcache["acctrmlist_600"],$str);
		$str=str_replace("{{bdmlist_600}}","BDM- ".$this->objcache["bdmlist_600"],$str);
	}
	else
	{
		$str=str_replace("{{recruitmentrmlist_600}}","",$str);
		$str=str_replace("{{acctrmlist_600}}","",$str);
		$str=str_replace("{{bdmlist_600}}","",$str);
	}

//Log::info($str);		
	preg_match_all('/{{[^}]*}}/', $str, $matches);
	if(!empty($matches)&&!empty($matches[0]))
	{
		foreach($matches[0] as $matchstr)
		{
				$tmpelem=substr($matchstr,2,-2);if(!isset($ppldata[$tmpelem]))$ppldata[$tmpelem]='';//Log::info($ppldata[$tmpelem]);
				$str=str_replace($matchstr,$ppldata[$tmpelem],$str);
			}
		}

		return $str;
	}
	

	function createFilesTab()
	{
		$fdirty=$this->recruitdata["dirty"];
		$dataarr=$this->recruitdata["peopledata"];
		$gthis=$this->gthis;
		$edituser=$this->edituser;
		$themehome=$this->themehome;
		$storagehome=$this->storagehome;
		$logarr=$this->recruitdata["modifylog"];
		$varid=$this->varid;

		
		$data="<div class=custom1 style='width:49%;float:left'>
		<legend class='new-recruit_legend'>Current Files</legend>
		<ul>";

			$fpath="$themehome/recruits/$varid";
			$storagepath="$storagehome/recruits/$varid";
			if (is_dir($storagepath)&&$handle = opendir($storagepath)) 
			{
				$optionsstr='<option></option>';
				$fileids=explode(",",$this->HRFileFieldsStr);
			foreach($fileids as $fileid)$optionsstr.="<option value='$fileid'>".$this->HRFieldNames[$fileid]."</option>";////

			$ii=0;
			while (false !== ($entry = readdir($handle))) 
			{
				if ($entry != "." && $entry != ".."&&substr($entry,0,3)!="OLD") 
				{
					$ii++;
					$titlestr='';
					$flatid="UniqueId_".$ii;
					$selectstr="<select id='SEL$flatid' onchange='filesSelected(\"$flatid\",\"$entry\");' class='form_hrm_select' style='width:50%'>$optionsstr</select>";////

					$pathinfo = pathinfo($entry);
					$extension = strtolower($pathinfo['extension']);
					if($extension=="jpg"||$extension=="png"||$extension=="jpeg"||$extension=="gif")$titlestr="<img src=\"$fpath/$entry\" width=400px>";
					else if($extension=="pdf"){$titlestr="<img src=\"$themehome/thumbs/$varid/$entry.gif\" width=400px>";$selectstr='';}
					else $selectstr='';
					$data.= "<li>$selectstr".($edituser==1?"<a href=# onclick='deleteFile(\"$entry\",\"$varid\");return false;'><img src='$themehome/images/x.jpg' height=10px></a> ":"")."<a title='$titlestr' class='tooltip tooltip1' href='$fpath/$entry' target=_BLANK><b>$entry</b></a><span id='SPAN$flatid'></span></li>";
				}
			}
			closedir($handle);
		}
		$data.="
	</ul>
</div>
<div class=custom1 style='width:49%;float:left'>
	<legend class='new-recruit_legend'>Old Files</legend>
	<ul>";

		$fpath="$themehome/recruits/$varid";
		$storagepath="$storagehome/recruits/$varid";
		if (is_dir($storagepath)&&$handle = opendir($storagepath)) 
		{
			while (false !== ($entry = readdir($handle))) 
			{
				if ($entry != "." && $entry != ".." &&substr($entry,0,3)=="OLD") 
				{
					$titlestr='';
					$pathinfo = pathinfo($entry);
					$extension = strtolower($pathinfo['extension']);
					if($extension=="jpg"||$extension=="png"||$extension=="jpeg"||$extension=="gif")$titlestr="<img src=\"$fpath/$entry\" width=400px>";
					$data.= "<li>".($edituser==1?"<a href=# onclick='deleteFile(\"$entry\",\"$varid\");return false;'><img src='$themehome/images/x.jpg' height=10px></a> ":"")."<a title='$titlestr' class='tooltip tooltip1' href='$fpath/$entry' target=_BLANK><b>$entry</b></a></li>";
				}
			}
			closedir($handle);
		}
		$data.="
	</ul>
</div>
<div style='clear:both'></div><div class='box_nrecrut' style='width:100%'><div style='width:49%;float:left'>";
$data.= $this->makeTextBox("genericfilename","form_new");
$data.= $this->makeTextBox("genericfileselect","","file");
$data.="</div><div style='width:49%;float:left'>
<label class=label-small_new  style='width:25%'>Upload and Split PDF</label><input type=file style='width:180px' name=pdfsplitfile id=pdfsplitfile><span id=fdpdfsplitfile></span>
</div></div>
<div style='clear:both'></div>
<fieldset>
	<legend class='new-recruit_legend'>Edit Logs</legend>
	<table class='footable table' cellpadding=0 cellspacing=0 style='border-bottom:black 2px solid;margin-bottom:20px'>
		<thead>
			<tr>
				<td class='table_hrm_heading_green'>Username</td>
				<td class='table_hrm_heading_green'>Date/Time</td>
				<td class='table_hrm_heading_green'>Key</td>
				<td class='table_hrm_heading_green'>New Values</td>
				<td class='table_hrm_heading_green'>Old Values</td>
			</tr>
		</thead>";

		if(is_array($logarr))
		{
			krsort($logarr);

			$i=0;
			foreach($logarr as $logkey=>$logval)
			{
				if(!$gthis->IsAdmin()&&$i>=200)break;
				$logline=explode("::",$logval);
				if($logkey!="createtime"&&$logkey!="updated"&&$logkey!=$createtime)
				{
					$j=0;
					$changedkeys=explode(",",$logline[1]);
					foreach($changedkeys as $changedkey)
					{
						$changedvals=explode("|",$changedkey);
						if($changedvals[0])
						{
							$i++;$j++;
							if(sizeof($changedvals)>3)$changedvals[2]=$changedvals[sizeof($changedvals)-1];

							if($j==1) $data.= "<tr><td>$logline[0]</td><td>".date("Y-m-d_H:i:s",$logkey)."</td><td>".$this->HRFieldNames[$changedvals[0]]."</td><td>$changedvals[2]</td><td>$changedvals[1]</td></tr>";
							else $data.= "<tr><td></td><td></td><td>".$this->HRFieldNames[$changedvals[0]]."</td><td>$changedvals[2]</td><td>$changedvals[1]</td></tr>";
						}
					}
				}
			}

			$createtime=$logarr["createtime"];
			$createuser=$logarr[$createtime];
			if($createuser)$data.= "<tr><td>$createuser</td><td>".date("Y-m-d H:i:s",$createtime)."</td><td colspan=3>Created</td></tr>";
		}

		$data.="</table></fieldset>

		<fieldset>
			<legend class='new-recruit_legend'>Mail Logs</legend>
			<table class='footable table' cellpadding=0 cellspacing=0 style='border-bottom:black 2px solid;margin-bottom:20px'>
				<thead>
					<tr>
						<td class='table_hrm_heading_green'>From</td>
						<td class='table_hrm_heading_green'>To</td>
						<td class='table_hrm_heading_green'>Subject</td>
						<td class='table_hrm_heading_green'>Status</td>
						<td class='table_hrm_heading_green'>Date</td>
					</tr>
				</thead>
				";
				$alist=$gthis->LoadAll("select * from hrms_emailqueue where eid='$varid' order by id desc ");
				foreach($alist as $aline)
				{
					$parts=unserialize($aline['data']);
					$check2=explode(" ",$parts['subject']);
					if(is_array($parts['to']))$parts['to']=implode("<br>",$parts['to']);

					if($dataarr['emailid']!="")
					{
						if(strstr($parts['to'],$dataarr['emailid'])||trim($check2[0])==$varid)
							$data.= "
						<tr>
							<td>$parts[from]</td>
							<td><div style='max-width:250px;overflow:hidden'>$parts[to]</div></td>
							<td>$parts[subject]</td>
							<td>$aline[status]</td> 
							<td>".str_replace(" ","_",$aline['completed'])."</td> 
						</tr>";
					}
				}

				$data.="</table></fieldset>";
				return $data;

			}

			function createTasksTab()
			{
				$gthis=$this->gthis;
				$varid=$this->varid;
				$themehome=$this->themehome;

				$data="<div style='width:100%;float:left'>";

				$data.="<table class='footable table' cellpadding=0 cellspacing=0 border=0>
				<thead><tr>
					<td class='table_hrm_heading_green'>Name</td>
					<td class='table_hrm_heading_green'>Assigned To</td>
					<td class='table_hrm_heading_green'>Due Date</td>
					<td class='table_hrm_heading_green'>Attachment</td>
					<td class='table_hrm_heading_green'>Status</td>
					<td class='table_hrm_heading_green'>Accepted On</td>
					<td class='table_hrm_heading_green'>Remarks</td>
					<td class='table_hrm_heading_green'>Created By</td>
					<td class='table_hrm_heading_green'></td>
				</tr></thead>";

				$tasksarr=$gthis->LoadAll("select * from hrms_tasks where empid='$varid' and creatorid!='System' and creatorid!='BounceMail' order by endtime desc");
				foreach($tasksarr as $taskline)
				{
					if($taskline['username']=="")$taskline['username']=$taskline['escalation2'];
			//$delstr="<a href=# onclick='deleteTask($taskline[id]);return false;'><img src='$themehome/images/x.jpg' height=10px></a>";

					$attachf="<a href='".$themehome."/uploads/".$taskline['username']."/".$taskline['attachment']."' target=_blank>".substr($taskline['attachment'],0,15)."</a>";
					$data.= "<tr><td>$taskline[name]</td><td>".str_replace(","," ",$taskline['username'])."</td><td title='Created: $taskline[created_at]'>$taskline[endtime]</td><td>$taskline[attachment]</td><td>$taskline[status]</td><td>$taskline[accepted]</td><td>$taskline[remarks]</td><td title=$taskline[id]>$taskline[creatorid]</td><td>$delstr</td></tr>";
				}

				$data.="<tr><td colspan=9><hr></td></tr>";$delstr="";

				$tasksarr=$gthis->LoadAll("select * from hrms_tasks where empid='$varid' and creatorid='System' order by endtime desc");
				foreach($tasksarr as $taskline)
				{
					if($taskline['username']=="")$taskline['username']=$taskline['escalation2'];
					if($gthis->IsAdmin()||strstr($gthis->HRCoreVars["HRManagerUsers"],$gthis->GetUserName()))$delstr="<a href=# onclick='deleteTask($taskline[id]);return false;'><img src='$themehome/images/x.jpg' height=10px></a>";

					$attachf="<a href='".$themehome."/uploads/".$taskline['username']."/".$taskline['attachment']."' target=_blank>".substr($taskline['attachment'],0,15)."</a>";
					$data.= "<tr><td>$taskline[name]</td><td>".str_replace(","," ",$taskline['username'])."</td><td title='Created: $taskline[created_at]'>$taskline[endtime]</td><td>$taskline[attachment]</td><td>$taskline[status]</td><td>$taskline[accepted]</td><td>$taskline[remarks]</td><td title=$taskline[id]>$taskline[creatorid]</td><td>$delstr</td></tr>";
				}

				$data.="</table></div>";
				return $data;
			}
			function createDispoTab()
			{
				$gthis=$this->gthis;

				$varid=$this->varid;
				$themehome=$this->themehome;
				$dataarr=$this->recruitdata["peopledata"];

				/*$recordDetails = DB::table('records')->where('id','=',$varid)->select('*')->get();
				$priority = $recordDetails[0]->priority;*/

				$data="<div style='width:100%;float:left'>";

				$data.="
				<div style='width:49%;float:left'><fieldset><legend class='new-recruit_legend'>Call Status</legend>";
					$data.="<p style='clear:both'>
					<label class=label-small_new  style='width:25%;' title=''>Disposition: </label>
					<select class='form_hrm_select' id='dialer_userstatus' name='dialer_userstatus' style='width:50%' onchange='dialerSubdisoSelect($(this).val());dispoChange(this.value);'>
					</select>
				</p>";
				$data.="<p style='clear:both'>
				<label class=label-small_new  style='width:25%;' title=''>Sub Disposition: </label>
				<select class='form_hrm_select' id='dialer_usersubstatus' name='dialer_usersubstatus' style='width:50%'>
				</select>
			</p>";
			$data.="<p style='clear:both'>
			<label class=label-small_new  style='width:25%;' title=''>Callback: </label>
			<input class='form_new form_new_amend datetimepicker_dthr' id='dialer_usercallback' name='dialer_usercallback'>
		</p>";
		/*$data.="<p style='clear:both'>
		<label class=label-small_new  style='width:25%;' title=''>Call Remarks: </label>
		<textarea id='dialer_userremarks' name='dialer_userremarks' style='width:70%' maxlength=250></textarea>
	</p>";*/

	    $data.="<p style='clear:both'>
		<label class=label-small_new  style='width:25%;' title=''>Call Remarks:</label>
		<textarea id='dialer_fullremarks' name='fullremarks' style='width:70%' maxlength=4000></textarea>
	</p>";
	$attemptsval="";
    
   		for($i=1;$i<=50;$i++)
   		{
   			$attemptsval.="<option value='".$i."'>".$i."</option>";
   		}

		$data.="<p style='clear:both'>
					<label class=label-small_new  style='width:25%;' title=''>Attempts: </label>
					<select class='form_hrm_select' id='attempt' name='attempt' style='width:50%'>'".$attemptsval."'
					</select>
				</p>";
   

		//Supervisor Comments - By Manish on 16/02/17
		/*if($dataarr['clientcode'])
			$supComnt = SupervisonComments::select('supvisor_comments','id','agent_comments')->where('clientcode','=',$dataarr['clientcode'])->first();

		$data.="<p style='clear:both'>
		<label class=label-small_new  style='width:25%;' title=''>Supervisor Comment: </label>
		<textarea id='dialer_userremarks' name='dialer_userremarks' style='width:70%' maxlength=250 readonly>".$supComnt['supvisor_comments']."</textarea>
		</p>";
		$data.="<p style='clear:both'>
		<label class=label-small_new  style='width:25%;' title=''>Agent Comment: </label>";

		if($supComnt['agent_comments'])
		$data.="<textarea id='agent_comment' name='agent_comment' style='width:70%' maxlength=250>".$supComnt['agent_comments']."</textarea>";
		else
		$data.="<textarea id='agent_comment' name='agent_comment' style='width:70%' maxlength=250></textarea>";

		$data.="<input type='hidden' id='sup_comnt_id' value='".$supComnt['id']."'>
	</p>";*/

	$data.="<p style='clear:both'>
	<label class=label-small_new  style='width:25%;' title=''>Flag as: </label>
	<select class='form_hrm_select' id='dialer_flag' name='dialer_flag'>
		<option value=''>Normal</option>
		<option value='VIP'>VIP</option>
	</select>
	<input type='hidden' id='priority' value=''>
</p>";
$data.="</fieldset></div>
<div style='width:49%;float:left'>
	<fieldset>  
		<label class=label-small_new  style='width:25%;' title=''>BTTC:</label>
		<select class='form_hrm_select' id='bttc_day' name='bttc_day' style='background-color:#FFD2D2'>
			<option value=''>Select Day</option>
			<option value='Monday'>Monday</option>
			<option value='Tuesday'>Tuesday</option>
			<option value='Wednesday'>Wednesday</option>
			<option value='Thursday'>Thursday</option>
			<option value='Friday'>Friday</option>
			<option value='Saturday'>Saturday</option>
		</select>

		<select class='form_hrm_select' id='bttc_hrs' name='bttc_hrs' style='margin-left:2%;background-color:#FFD2D2'>
			<option value=''>Select Hour</option>
			<option value='9-10'>9-10</option>
			<option value='10-11'>10-11</option>
			<option value='11-12'>11-12</option>
			<option value='12-1'>12-1</option>
			<option value='1-2'>1-2</option>
			<option value='2-3'>2-3</option>
			<option value='4-5'>4-5</option>
			<option value='6-7'>6-7</option>
			";

			/*$recordDetails = $recordDetails[0];*/
			$bttc = explode(":",$dataarr['bttc']);

			$bttc_day = $bttc[0];
			$bttc_hrs = $bttc[1];

                /*for($i=1;$i<=24;$i++)
                {
                        $data.="<option value='".str_pad($i,"2","0",STR_PAD_LEFT)."'>".str_pad($i,"2","0",STR_PAD_LEFT)."</option>";
                    }*/

                    $data.="</select></fieldset>
                    <script>
                    	\$(document).ready(function()
                    	{
                    		\$('#bttc_day').val('".$bttc_day."');
                    		\$('#bttc_hrs').val('".$bttc_hrs."');
                    	});
                    </script>
                    ";

                    $latestCall=CRMCall::where('crm_id','=',$this->varid)->where('ts_Call','>','0')->orderBy("created_at","DESC")->first();

                    $data.="<fieldset><legend class='new-recruit_legend'>Alt #</legend>";

                    $nextempty="";
                    $data.="<p style='clear:both'>
                    <label class=label-small_new  style='width:25%;' title=''>Main #: </label>
                    <input class='form_new form_new_amend' value='".$dataarr["mobile"]."' disabled=disabled><a href=# class='btn btn-default' onclick='dialerQuickOpen($this->varid,\"".$dataarr["mobile"]."\",\"Progressive\",\"\",0);return false;'><i class='fa fa-phone'></i></a>
                </p>";
                for($i=1;$i<=10;$i++)
                {
                	if(!empty($dataarr["altphone$i"]))
                	{
                		$data.="<p style='clear:both'>
                		<label class=label-small_new  style='width:25%;' title=''>Alt #$i: </label>
                		<input class='form_new form_new_amend' id='dialer_altphone_lbl_$i' name='dialer_altphone_lbl_$i' value='".$dataarr["altphone_lbl_$i"]."' disabled=disabled placeholder='Description'>
                		<input class='form_new form_new_amend' id='dialer_altphone$i' name='dialer_altphone$i' value='".$dataarr["altphone$i"]."' disabled=disabled placeholder='##########'>

                		<a href=# class='btn btn-default' onclick='dialerDelAlt($i,$this->varid);return false;'><i class='fa fa-minus'></i></a>
                		<a href=# class='btn btn-default' onclick='dialerQuickOpen($this->varid,\"".$dataarr["altphone$i"]."\",\"Manual\",\"\",0);return false;'><i class='fa fa-phone'></i></a>
                	</p>";
                }
                else if($nextempty=="")$nextempty=$i;
            }
            if($nextempty!="")
            {
            	$data.="<p style='clear:both'>
            	<label class=label-small_new  style='width:25%;' title=''>Alt #$nextempty: </label>
            	<input class='form_new form_new_amend' id='dialer_altphone_lbl_$nextempty' name='dialer_altphone_lbl_$nextempty' value='' placeholder='Description'>
            	<input class='form_new form_new_amend' id='dialer_altphone$nextempty' name='dialer_altphone$nextempty' value='' placeholder='##########'><a href=# class='btn btn-default' onclick='dialerAddAlt($nextempty,$this->varid);return false;'><i class='fa fa-plus'></i></a>
            </p>";
        }

        $data.="</fieldset>

        <fieldset><legend class='new-recruit_legend'>Conf #</legend>
        	<p style='clear:both'>
        		<label class=label-small_new  style='width:25%;' title=''>Number : </label>
        		<input type=text id=dialerConfNumberTxt class='form_new form_new_amend' value='' placeholder='Conference Call'><a href=# class='btn btn-default' onclick='dialerAddConfCall();return false;'><i class='fa fa-phone'></i></a>
        	</p>
        </fieldset></div>

        <div style='clear:both;width:100%;'>
        	<div style='width:49%;float:left'>
        		<select class='form_hrm_select' id='serv_vs_prod' name='serv_vs_prod' style='width:49%;background: #f4f4f4;background-image: none;' disabled>
        			<option value=''>Service vs Product</option>
        			<option value='Service Requirement'>Service Requirement</option>
        			<option value='Product Interest'>Product Interest</option>
        			<option value='Complaint'>Complaint</option>
        		</select>

        		<select class='form_hrm_select' id='resolution' name='resolution' style='width:50%;background: #f4f4f4;background-image: none;' disabled>
        			<option value=''>Resolution</option>
        			<option value='Resolved'>Resolved</option>
        			<option value='Clarified'>Clarified</option>
        			<option value='Pending With Customer'>Pending With Customer</option>
        			<option value='Pending-Followup Required'>Pending-Followup Required</option>
        		</select>
        	</div>          

        	<div style='width:49%;float:right'>
        		<select class='form_hrm_select' id='satisfy' name='satisfy' style='width:49%;background: #f4f4f4;background-image: none;' disabled>
        			<option value=''>Satisfaction</option>
        			<option value='Yes'>Yes</option>
        			<option value='No'>No</option>
        			<option value='Neutral'>Neutral</option>
        		</select>

        		<select class='form_hrm_select' id='final_call_assess' name='final_call_assess' style='width:50%;background: #f4f4f4;background-image: none;' disabled>
        			<option value=''>Final Call Assessment</option>
        			<option value='Very Good Call With Customer'>Very Good Call With Customer</option>
        			<option value='Ok Call'>Ok Call</option>
        			<option value='Not Interested Customer'>Not Interested Customer</option>
        			<option value='Iritated Customer'>Iritated Customer</option>
        			<option value='Angry'>Angry</option>
        		</select>
        	</div>
        </div><br><br><br>

        <div style='display:none'>
        	<style>
        		.gritter-b-center{
        			position:fixed;	
        			left:33%;
        			right:33%;
        			top:33%;
        			background:#FFFFFF;
        			background-image:url('/assets/images/Emoticons/Very_good_Call.gif') no-repeat;
        		}
        	</style>
        	<div id='goodCall'><img src='/assets/images/Emoticons/Very_good_Call.gif' height='240' width='255'></div>
        	<div id='okCall'><img src='/assets/images/Emoticons/Ok_Call.gif' height='240' width='255'></div>
        	<div id='notInterest'><img src='/assets/images/Emoticons/Not_Interested.gif' height='240' width='255'></div>
        	<div id='iritCust'><img src='/assets/images/Emoticons/Irate.gif' height='240' width='255'></div>
        	<div id='angry'><img src='/assets/images/Emoticons/Angry.gif' height='240' width='255'></div>
        </div>	  
        <div style='clear:both'></div>

        <script>


        	function dispoChange(dispo){

        		if(kstychCall['ts_Talk']<1||Math.ceil(((kstychCall['ts_now']-kstychCall['ts_Talk'])/1000))<10)
        		{		
        			return;	
        		}

        		if(dispo=='Contacted - FollowUp - Specific' || dispo=='Contacted - Follow-Up - Generic')
        		{
        			document.getElementById('serv_vs_prod').disabled=false;
        			document.getElementById('serv_vs_prod').style.background='#77DD77';

        			document.getElementById('resolution').disabled=false;
        			document.getElementById('resolution').style.background='#77DD77';

        			document.getElementById('satisfy').disabled=false;
        			document.getElementById('satisfy').style.background='#77DD77';

        			document.getElementById('final_call_assess').disabled=false;
        			document.getElementById('final_call_assess').style.background='#77DD77';
        		}
        		else
        		{
        			document.getElementById('serv_vs_prod').disabled=true;
        			document.getElementById('serv_vs_prod').style.background='#f4f4f4';
        			document.getElementById('serv_vs_prod').selectedIndex=0;

        			document.getElementById('resolution').disabled=true;
        			document.getElementById('resolution').style.background='#f4f4f4';
        			document.getElementById('resolution').selectedIndex=0;              

        			document.getElementById('satisfy').disabled=true;
        			document.getElementById('satisfy').style.background='#f4f4f4';
        			document.getElementById('satisfy').selectedIndex=0;

        			document.getElementById('final_call_assess').disabled=true;
        			document.getElementById('final_call_assess').style.background='#f4f4f4';
        			document.getElementById('final_call_assess').selectedIndex=0;
        		}
        	}


        	var dialerdispoarray={};var dispoClassArray={};
        	dialerdispoarray['']='';\n";


        	$mastersdata=$gthis->getCompanyMaster($client);
        	if(empty($mastersdata['dialerDispoList']))$mastersdata['dialerDispoList']=$gthis->HRCoreVars['dialerDispoList'];

        	$dispoarr=explode("~",$mastersdata['dialerDispoList']);
        	foreach($dispoarr as $dispo)
        	{
        		if(!empty($dispo))
        		{
        			$dispoprts=explode("|",$dispo);
        			if(sizeof($dispoprts)>=3)
        			{
        				$data.="dialerdispoarray['$dispoprts[1]']='$dispoprts[2]';dispoClassArray['$dispoprts[0]']='$dispoprts[1]';";
        			}
        		}
        	}

        	$data.="

        	function dialerDisoSelect()
        	{
        		if(dialerdispoarray)
        		{
        			var dispolist=[];
        			for (var key in dialerdispoarray) {
        				dispolist.push(key);
        			}
        			updateJSSelect('dialer_userstatus',dispolist);
        		}
        	}
        	function dialerSubdisoSelect(dispo)
        	{
        		if(dialerdispoarray)
        		{
        			if(dialerdispoarray[dispo])
        			{
        				dispolist=dialerdispoarray[dispo].split(',');
        				updateJSSelect('dialer_usersubstatus',dispolist);
        			}
        		}
        	}
        	dialerDisoSelect();
        </script>";
       // Relationship Tagging
        if(Auth::user()->username=='B654321')
        {
          $relationshipServices = DB::table('relationship_service')->get();
		  $data.='<hr/><legend class="new-recruit_legend">Relationship Taggiing</legend>
		  <p id=chkboxrelship><input type=checkbox onclick="enableRelationships();return false;" id=relchkboxenable> Click to Tag Relationships</p>
				<div class="row">
					<div class="col-sm-3">
						<select class="select2multi" id="relationshipService" name="" style="width:100%;" onchange="changeRelationshipCategory(this.value);return false;">
							<option value="">Select Service</option>';
			foreach($relationshipServices as $value){
				$data.='<option value="'.$value->id.'">'.$value->title.'</option>';
			}
				$data.='</select>
					</div>
					<div class="col-sm-3">
						<select class="select2multi" id="relationshipCategory" name="" style="width:100%;" onclick="changeRelationshipSubCategory(this.value);return false;"></select>
					</div>
					<div class="col-sm-3">
						<select class="select2multi" id="relationshipSubCategory" name="" style="width:100%;"></select>
					</div>
					<div class="col-sm-3">
						<button class="btn btn-success" onclick="addRelationship();return false;">Add</button>
					</div>
				</div>
				<div class="row">
					<div class="col-sm-4" style="padding:5px 0;">
						<label class="label-small_new" style="width:25%;">Service 1: </label>
						<input type="text" class="form_new form_new_amend disabled" id="dialerdata_service1-'.$varid.'" name="" style="width:70%" disabled="disabled" />
					</div>
					<div class="col-sm-4" style="padding:5px 0;">
						<label class="label-small_new" style="width:25%;">Service 2: </label>
						<input type="text" class="form_new form_new_amend disabled" id="dialerdata_service2-'.$varid.'" name="" style="width:70%" disabled="disabled"/>
					</div>
					<div class="col-sm-4" style="padding:5px 0;">
						<label class="label-small_new" style="width:25%;">Service 3: </label>
						<input type="text" class="form_new form_new_amend disabled" id="dialerdata_service3-'.$varid.'" name="" style="width:70%" disabled="disabled"/>
					</div>
					<div class="col-sm-4" style="padding:5px 0;">
						<label class="label-small_new" style="width:25%;">Service 4: </label>
						<input type="text" class="form_new form_new_amend disabled" id="dialerdata_service4-'.$varid.'" name="" style="width:70%" disabled="disabled"/>
					</div>
					<div class="col-sm-4" style="padding:5px 0;">
						<label class="label-small_new" style="width:25%;">Service 5: </label>
						<input type="text" class="form_new form_new_amend disabled" id="dialerdata_service5-'.$varid.'" name="" style="width:70%" disabled="disabled"/>
					</div>
					<div class="col-sm-4" style="padding:5px 0;">
						<label class="label-small_new" style="width:25%;">Service 6: </label>
						<input type="text" class="form_new form_new_amend disabled" id="dialerdata_service6-'.$varid.'" name="" style="width:70%" disabled="disabled"/>
					</div>
				</div><hr style="padding:5px 0;"/>
				<script>
				function changeRelationshipCategory(id){
					if(id != ""){
						doAjax("dialer/relationship?type=category&id="+id,"","relationshipCategory","","","GET");
					}
				}
				function changeRelationshipSubCategory(id){
					if(id != ""){
						doAjax("dialer/relationship?type=subCategory&id="+id,"","relationshipSubCategory","","","GET");
					}
				}
				var service = 1;
				if(typeof customerDispofields == "undefined")var customerDispofields = {};
				
				function addRelationship(){
					var relationshipService = $("#relationshipService option:selected").text();
					var relationshipCategory = $("#relationshipCategory option:selected").text();
					var relationshipSubCategory = $("#relationshipSubCategory").val();
					if(service <= 6)
					{
						if(relationshipService!="" && relationshipCategory!="" && relationshipSubCategory!="")
						{
							$("#dialerdata_service"+service+"-'.$varid.'").val(relationshipService+" -- "+relationshipCategory+" -- "+relationshipSubCategory);
							if(typeof customerDispofields['.$varid.'] == "undefined")
							{
                           		customerDispofields['.$varid.']={};
                           		customerDispofields['.$varid.']["dialerdata_service"+service]="";	
							}
							customerDispofields['.$varid.']["dialerdata_service"+service] = relationshipService+" -- "+relationshipCategory+" -- "+relationshipSubCategory;
							service++;
						
						
							$("#relationshipService").select2("data", {id:"", text:""});
							$("#relationshipCategory").select2("data", {id:"", text:""});
							$("#relationshipSubCategory").select2("data", {id:"", text:""});
						}else{
							simpleNotification("error","topRight","please select Service Category and SubCategory");
						}
					}
				}
				function enableRelationships()	
				{		
					if(kstychCall["ts_Talk"]<1||Math.ceil(((getNowTS()-kstychCall["ts_Talk"])/1000))<10)
					{		
						$("#relchkboxenable").removeAttr("checked");		return;	
					}		
					$("#chkboxrelship").hide();		
					$("#dialerdata_service1-'.$varid.'").prop("disabled",false);				
				 	$("#dialerdata_service2-'.$varid.'").prop("disabled",false);				
				 	$("#dialerdata_service3-'.$varid.'").prop("disabled",false);				
				 	$("#dialerdata_service4-'.$varid.'").prop("disabled",false);				
				 	$("#dialerdata_service5-'.$varid.'").prop("disabled",false);				
				 	$("#dialerdata_service6-'.$varid.'").prop("disabled",false);	
				}
				</script>';
        }
        else
        {
        	if(empty($mastersdata['dialerCustomHTML']))$mastersdata['dialerCustomHTML']=$gthis->HRCoreVars['dialerCustomHTML'];

        	$userdatahtml=str_replace("__EQ__","=",$mastersdata['dialerCustomHTML']);
        	$userdatahtml=str_replace("__PLUS__","+",$userdatahtml);
        	$userdatahtml=str_replace("{{varid}}",$this->varid,$userdatahtml);

        	$data.=$userdatahtml;
        }
        
// End Relationship Tagging


        
//Log::info($userdatahtml);
        $data.="<hr></div>";
        //$data.="</div>";
//Log::info($data);
        return $data;
    }


	function createCallsTab()
	    {
	        $data="<fieldset><legend class='new-recruit_legend'>Calls History</legend>";

	        $data.="    <div class=custom1 style='width:100%;'>
	        <h2></h2>";

	        $data.="<hr><br><table class='table kDataTable' cellpadding=0 cellspacing=0 border=0>
	        <thead><tr>
	            <td>#</td>
	            <td class='table_hrm_heading_green'>Start</td>
	            <!--<td class='table_hrm_heading_green'>Length*</td>-->
	            <td class='table_hrm_heading_green'>User</td>
	            <td class='table_hrm_heading_green'>Number</td>
	            <td class='table_hrm_heading_green'>Type</td>
	            <!--<td class='table_hrm_heading_green'>Status*</td>-->
	            <td class='table_hrm_heading_green'>Disposition</td>
	            <td class='table_hrm_heading_green'>SubDispo</td>
	            <td class='table_hrm_heading_green'>Callback</td>
	            <td class='table_hrm_heading_green'>Remarks</td>
	            <td class='table_hrm_heading_green'>Custom</td>
	            <td class='table_hrm_heading_green'>BTTC</td>
	            <td class='table_hrm_heading_green'>Service vs Product</td>
	            <td class='table_hrm_heading_green'>Resolution</td>
	            <td class='table_hrm_heading_green'>Satisfaction</td>
	            <td class='table_hrm_heading_green'>Final Call Assessment</td>
	        </tr></thead>";
	//Log::info($this->varid);
	        $k=1;
	        $alist=CRMCallArchive::where('crm_id','=',$this->varid)->where('ts_Close','>','0')->orderBy("created_at","DESC")->get();

	        $records = DB::table('records')->where('id','=',$this->varid)->select('bttc','service_vs_product','resolution','satisfaction','final_call_assessment')->get();

	        $callarraid='';
    		foreach($alist as $aline)
    		{

    			$callarraid.=$aline->id.",";
    		}

    		$callarraid=substr($callarraid,0,-1);
    		$callarraid=explode(",", $callarraid);

       		$alist_remark=DB::table('full_remark')->select('fullremark','call_id')->whereIn('call_id',$callarraid)->get();
    		foreach($alist_remark as $aline)
    		{
    			$remarkval[$aline->call_id]=$aline->fullremark;

    		}

	        foreach($alist as $aline)
	        {
	            $userdata="";
	            $fullremarkvalue='';
	            $userdataarr=json_decode($aline->userdata,true);
	            if(is_array($userdataarr))foreach($userdataarr as $userdatavar=>$userdataval)
	            {
	                $userdata.="<tr><td>$userdataval</td></tr>";
	            }
	            if(trim($userdata)!="")$userdata="<table>".$userdata."</table>";

	            $dispname="";if($aline->user_id>0){$tuser=User::find($aline->user_id);$dispname=$tuser->dispname();}

	           
	            // $records = DB::table('records')->where('id','=',$aline->crm_id)->select('bttc','service_vs_product','resolution','satisfaction','final_call_assessment')->get();
	            $fullremarkvalue=$remarkval[$aline->id];
	            if($fullremarkvalue=="")
	            {
                    $fullremarkvalue=$aline->userremarks;
	            }

	            $data.="<tr>
	            <td>$k</td>
	            <td class=''>".date("Y-m-d H:i:s",strtotime($aline->created_at)-(Auth::user()->timezone*60))."</td>
	            <!--<td class=''>".round($aline->callsec/1000,2)."</td>-->
	            <td class=''>".$dispname."</td>
	            <td class=''>".$aline->number."</td>
	            <td class=''>".$aline->type."</td>
	            <!--<td class=''>".$aline->status."</td>-->
	            <td class=''>".$aline->userstatus."</td>
	            <td class=''>".$aline->usersubstatus."</td>
	            <td class=''>".date("Y-m-d H:i:s",strtotime($aline->usercallback)-(Auth::user()->timezone*60))."</td>
	            <td class=''>".$fullremarkvalue."</td>
	            <td class=''>".$userdata."</td>
	            <td class=''>".$records[0]->bttc."</td>
	            <td class=''>".$records[0]->service_vs_product."</td>
	            <td class=''>".$records[0]->resolution."</td>
	            <td class=''>".$records[0]->satisfaction."</td>
	            <td class=''>".$records[0]->final_call_assessment."</td>
	        </tr>";
	        $k++;
	    }
	    $data.="</table>";

	    $data.="</div>";
	    $data.="</fieldset>";

	    return $data;
	}

	//For Creating Questionaire contain
function createQaireTab()
{
	$varid=$this->varid;
	$dataarr=$this->recruitdata["peopledata"];

	$question = explode(",",$dataarr['question']);

	$qid='';
	$auth_ques_count = 5;
		//$where = 'id = 1';
	
	$auth_questions=DB::table('authentication_questions')->inRandomOrder()->limit($auth_ques_count)->get();
    if($dataarr['question']==""){
        $questions = DB::table('question')->where('type','P')->whereIn('question_no',$question)->get();
    }
	else{
   		$questions = DB::select(DB::raw("SELECT * FROM question WHERE type='P' and question_no IN(".$dataarr['question'].") ORDER BY FIELD(question_no,".$dataarr['question'].")"));
   }
	
   $questions_details=array();
   $questionhistory='';
   $question_history='';
   	if($dataarr['question'] && $dataarr['clientcode'])
   	{
   		$questions_details = DB::select(DB::raw("SELECT distinct question FROM questionaire_details WHERE cust_id=".$dataarr['clientcode']." and question IN(".$dataarr['question'].") "));
   
  		foreach ($questions_details as $questionhistory) {
  		
  			$question_history.=$questionhistory->question.",";
  		}
    	$question_history=substr($question_history,0,-1);
    	$question_history=explode(",", $question_history);
  	}
   
	$supervisorcomments='';
	$agent_comments='';

	$data = "<fieldset><div style='font-size:10px'><!-- row-app -->
	<div class='row row-app'>
		<div class='col-xs-12'>
			<div class='col-separator col-separator-first box col-unscrollable'>
				<div class='col-table' style='padding-left: 13px;padding-right: 7px;'>

					<div class='innerAll' style='background: #fff;'>";

					//Supervisor Recommendation - By Manish on 20-02-17
					//Supervisor Recommendation - By Prashant Jadhav on 07-11-17
						if($dataarr['clientcode'])
						{
							$supComnt = DB::table('DU_CRM_SUPERVISOR_COMMENTS')->where('V_CUSTID','=',$dataarr['clientcode'])->orderBy('V_LAST_REVIEWED_ON','DESC')->limit(3)->get();
						}

						
						foreach($supComnt as $supervisorcomments)
                       	{
                          
                       		$data.="<p style='clear:both'><br>
								<label style='width:15%;' title=''>Supervisor Recommendation:</label>
							<textarea id='dialer_userremarks' name='dialer_userremarks' style='width:30%;height:100px;' maxlength=250  placeholder='Only 250 Characters' readonly>".$supervisorcomments->T_BM_INSTRUCTION."</textarea>&nbsp;&nbsp;&nbsp;&nbsp;<label style='width:15%;' title=''>BM Product Recommendation:</label><textarea id='dialer_userremarks' name='dialer_userremarks' style='width:20%;height:100px;' maxlength=250  placeholder='Only 250 Characters' readonly>".$supervisorcomments->T_BM_PRODUCT_RECO."</textarea><br><br>
							<label style='width:15%;' title=''>Last Review On:</label>
							<label style='width:30%;' title=''>".$supervisorcomments->V_LAST_REVIEWED_ON."</label>";
                       		$data.="&nbsp;&nbsp;&nbsp;<label style='width:15%;' title=''>Agent Comment: </label>";

							if($supervisorcomments->agent_comments)
							$data.="<textarea id='".$supervisorcomments->id."_agent_comment' name='agent_comment' style='width:20%;height:100px;' maxlength=250 placeholder='Only 250 Characters'>".$supervisorcomments->agent_comments."</textarea>";
							else
							$data.="<textarea id='".$supervisorcomments->id."_agent_comment' name='agent_comment' style='width:20%;height:100px;' maxlength=250 placeholder='Only 250 Characters'></textarea>";
							$data.="</p><div class='container'>
							<input type=button id='".$supervisorcomments->id."_submitComments' class='btn btn-info' value='Submit' onclick='updateagentcomments(".$supervisorcomments->id.");'style=' margin: 5px 0 5px 660px;'>
							</div>";
                       	}

				$data.="<legend class='task_legend'>Primary Questions</legend>

				<div id='primary_ques' class='primary_ques'>";
					foreach($questions as $key=> $primary_question){

					$data.="<div class='row' id='subParent".$primary_question->question_no."' data-parent='".$primary_question->question_no."' style='border:solid #D3D3D3 2px;border-radius:5px;margin-top:5px;'>
							<div class='row' id='rowDiv1".$primary_question->question_no."'>
								<div class='col-md-4' id='appendChild1".$primary_question->question_no."'>
									<div id='childParentDiv".$primary_question->question_no."'>";


                                   if($primary_question->compulsory_qes =='imp')
									{
                                      $data.="<div class='panel panel-warning panel-heading' id='parentColorDiv".$primary_question->question_no."' style='background-color:#CD6155;cursor:pointer'>";
									}
                                    else if(in_array($primary_question->question_no,$question_history))
                                    {
                                       	$data.="<div class='panel panel-warning panel-heading' id='parentColorDiv".$primary_question->question_no."' style='background-color:#99ffcc;cursor:pointer'>";
                                    }else if($key%2!=0)
									{
										$data.="<div class='panel panel-warning panel-heading' id='parentColorDiv".$primary_question->question_no."' style='background-color:#FFFFFF;cursor:pointer'>";
									}
									else
									{
										$data.="<div class='panel panel-warning panel-heading' id='parentColorDiv".$primary_question->question_no."' style='background-color:#e6e5ef;cursor:pointer'>";
									}
										
									$data.="<div class='question' data-ques='".$primary_question->question_no."' style='margin: 5px 0;'><b>Q.".$primary_question->question_no." ".$primary_question->questions."</b>
										<input type='hidden' value='".$primary_question->questions."' id='questText_".$primary_question->question_no."'>
									</div>
									<div class='options_div' id='options_div".$primary_question->question_no."'>";

										for($i=1;$i<=10;$i++)
										{ 
											$opt_no = 'opt_'.$i;
											if($primary_question->$opt_no != '')
											{
												$data.="
												<label class='options radio-inline' data-ques='".$primary_question->question_no."' data-ans='".$i."'  id='label".$primary_question->question_no.$i."' style='font-size:10px'>
													<input type='radio' id='opt_".$primary_question->question_no.$i."' name='opt_".$primary_question->question_no."' style='margin:0; padding:0;'>&nbsp;&nbsp;".$primary_question->$opt_no."</label><br />";
												}
											}
											$data.="
											<textarea class='remarks form-control' name='remark".$primary_question->question_no."' id='remark".$primary_question->question_no."' style='border: 1px solid #cccccc;' cols='2' rows='2'></textarea>
											<input type='hidden' id='level".$primary_question->question_no."' name='level".$primary_question->question_no."' value='1'>
											<input type='hidden' id='levelVal".$primary_question->question_no."' value='".$primary_question->question_no."'>
										</div>
									</div>";
									if($key==0){
										$data.="<input type='hidden' id='parent".$primary_question->question_no."' name='parent1' value='".$qid."'>";}
										else
										{	
											$data.="<input type='hidden' id='parent".$primary_question->question_no."' name='parent1".$primary_question->question_no."' value='".$primary_question->question_no."'>";
										}
										$data.="
									</div>
								</div>
							</div>

							<div class='row' id='rowDiv2".$primary_question->question_no."'>
							</div>
							<div class='row' id='rowDiv3".$primary_question->question_no."'>
							</div>


						</div>
						";
					}
					$data.="
					<hr style='clear:both;padding: 4px 0 2px;' />
					<input type='hidden' id='questionDateTime'  value=''>
					<input type='button' class='btn btn-success' value='Save' id='submitQuestionAire'>
				</div>

			</div>

			<script>
				$(document).ready(function(){

					var questionArray = {};
					var authQuestionArray = {};
					var appendChild=1;

					$('.options_div').hide();
					$('#authArea').hide();
					$('input:radio:checked').prop('checked', false);

					var count=0;

					$('#auth_question').on('click', '.options', function(){


						var authQues = $(this).data('rad');
						var authKey = $('#authKey_'+authQues).val();

						authQuestionArray['auth_'+authKey]={}; 
						authQuestionArray['auth_'+authKey]['auth_ques'] = $('#authQuestText_'+authQues).val();
						authQuestionArray['auth_'+authKey]['auth_opt'] = $(this).text();

						count++;
					});

					$('#submit').click(function(){
						if ($('.authQuestion[type=radio]:checked').length == auth_ques_count) {  
							$('#form-group').hide();
							$('#authArea').show();
							$('#submit').hide();
							$('.authQuestion').attr('disabled','disabled');
						}
						else {
							alert('Please answer all authentication questions'); 
						}
					});

					$('#primary_ques').on('click', '.question', function(){

						if(count==0)
						{
							document.getElementById('questionDateTime').value='".date("Y-m-d H-i-s")."';
						}

						var ques = $(this).data('ques');
						$('#options_div' + ques).toggle();
					});

					var radCount=0;
					var subParent;
					var appendOnce = 1;

					$('#primary_ques').on('click', '.options', function(){
						var ques = $(this).data('ques');
						var ans = $(this).data('ans');
						var currQues='';

						var priParentQues;

						if(parseInt($('#level'+ques).val())==1)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							subParent = priParentQues;

							questionArray['Q-'+priParentQues] = {};

							questionArray['Q-'+priParentQues]['prim_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['prim_response']=$(this).text();

							questionArray['Q-'+priParentQues]['prim_txt'] = '';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['prim_txt']=$(this).val();
							});

							var hideRadioElement = $(this).parent();
							var countLabel = hideRadioElement.children().size();

							var radEleId = hideRadioElement.attr('id');

							var labels = document.getElementById(radEleId).querySelectorAll('label');

							for(var f=1;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}

							radCount++;
						}

						if(parseInt($('#level'+ques).val())==2)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol1_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol1_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol1_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';

							}

							for(var f=2;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}


						}

						if(parseInt($('#level'+ques).val())==3)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol2_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol2_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol2_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol2_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';

							}

							for(var f=3;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}
						}

						if(parseInt($('#level'+ques).val())==4)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol3_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol3_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol3_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol3_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';

							}

							for(var f=4;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}
						}

						if(parseInt($('#level'+ques).val())==5)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol4_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol4_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol4_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol4_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';
							}

							for(var f=5;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}
						}

						if(parseInt($('#level'+ques).val())==6)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol5_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol5_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol5_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol5_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';

							}

							for(var f=6;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}
						}

						if(parseInt($('#level'+ques).val())==7)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol6_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol6_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol6_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol6_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';

							}

							for(var f=7;f<8;f++)
							{
								questionArray['Q-'+priParentQues]['fol'+f+'_ques'] = '';
								questionArray['Q-'+priParentQues]['fol'+f+'_response']='';
								questionArray['Q-'+priParentQues]['fol'+f+'_txt']='';
							}
						}

						if(parseInt($('#level'+ques).val())==8)
						{
							var element = $(this).parent().parent().parent().parent().parent().parent();
							priParentQues = element.attr('data-parent');

							questionArray['Q-'+priParentQues]['fol7_ques'] = $('#questText_'+ques).val();
							questionArray['Q-'+priParentQues]['fol7_response']=$(this).text();

							questionArray['Q-'+priParentQues]['fol7_txt']='';

							$('#remark'+ques).keyup(function() {
								questionArray['Q-'+priParentQues]['fol7_txt']=$(this).val();
							});

							var setAttrElement = $(this).parent().parent().parent();
							setAttrElement.attr('for','active');

							var hideElement = $(this).parent().parent().parent().parent();
							var countDiv = hideElement.children().size();

							for(var s=0;s<countDiv;s++)
							{
								var childEle = hideElement.children()[s];

								if(childEle.getAttribute('for') != 'active')
									document.getElementById(childEle.id).style.display='none';

							}
						}

						if(appendOnce%2==0) {
							loadQuestions(ques, ans);
						}
						appendOnce++;
					});

					function loadQuestions(ques, ans) {
						var level = parseInt($('#level'+ques).val());
						var next_level = level+1;
						var parent_id = '".$qid."';

						if(level==1)
						{
							prev_ques='';
						}

						var levelVar = parseInt($('#levelVal'+ques).val());

						<!-- $('#options_div'+prev_ques).attr('style','display:none');-->
						$('#options_div'+$('#parent'+level+ques).val()+' input[type=radio]').attr('disabled','disabled');
						$.ajax({
							url: '/questionare/'+ques+'/'+ans+'/'+next_level,
							error: function() {
								$('#childs'+ques).html('<p></p>');
							},
							dataType: 'html',
							success: function(data) {

								var childParentDiv1 = null;
								var rowDiv1 = null;
								var childParentDiv = null;
								var childParentDiv2 = null;

								var rowDiv = $('#childParentDiv'+ques).parent().parent().attr('id');

								rowDiv1 = document.getElementById(rowDiv).nextElementSibling;
								if(rowDiv1 != undefined)
								{
									var rowDiv1ID = rowDiv1.id;
									$('#'+rowDiv1ID).html('');

									var rowDiv2 = document.getElementById(rowDiv).nextElementSibling.nextElementSibling;
									if(rowDiv2 != undefined)
									{
										var rowDiv2ID = rowDiv2.id;
										$('#'+rowDiv2ID).html('');
									}
								}

								childParentDiv = $('#childParentDiv'+ques).parent().attr('id');

								childParentDiv1 = document.getElementById(childParentDiv).nextElementSibling;

								if(childParentDiv1 != null)
								{
									var childParentDiv1ID = childParentDiv1.id;
									$('#'+childParentDiv1ID).remove();

									childParentDiv2 = document.getElementById(childParentDiv).nextElementSibling;

									if(childParentDiv2 != undefined)
									{
										var childParentDiv2ID = childParentDiv2.id;
										$('#'+childParentDiv2ID).remove();
									}
								}

								if(level<3)
								{
									$('#rowDiv1'+subParent).append('<div class=\"col-md-4\" id=\"appendChild'+appendChild+ques+'\"></div>');					
								}

								if(level>=3 && level<=5)
								{
									$('#rowDiv2'+subParent).append('<div class=\"col-md-4\" id=\"appendChild'+appendChild+ques+'\"></div>');					
								}

								if(level>=6 && level<=8)
								{
									$('#rowDiv3'+subParent).append('<div class=\"col-md-4\" id=\"appendChild'+appendChild+ques+'\"></div>');					
								}

								$('#appendChild'+appendChild+ques).append(data);

								var parentColor = document.getElementById('parentColorDiv'+subParent).getAttribute('style');

								for(var c=0;c<=8;c++){
									var colorDiv = document.getElementById('subParent'+subParent).getElementsByClassName('childDiv')[c];

									if(colorDiv!=undefined)
										colorDiv.setAttribute('style',parentColor);
								}
							}
						});
						prev_ques = ques;
						appendChild++;

					}

					$('#submitQuestionAire').click(function()
					{ 
						if(radCount==0)
						{
							alert('Please select some options first');
							return;
						}

						var postdata='varid='+$('#varid').val();
						postdata+='&mobile='+'".$dataarr["mobile"]."';
						postdata+='&client='+'".$dataarr["client"]."';
						postdata+='&clientcode='+'".$dataarr["clientcode"]."';
						postdata+='&firstname='+'".$dataarr["firstname"]."';
						postdata+='&questionDateTime='+$('#questionDateTime').val();
						postdata+='&questionArray='+encodeURIComponent(JSON.stringify(questionArray));
						doAjax('questionare',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
					});

					



				});
				function updateagentcomments(id){

					
					var agent_comment = $('#'+id+'_agent_comment').val();
						if(agent_comment)
						{
							
							var postdata='id='+id;
							postdata+='&agent_comment='+agent_comment;
							postdata+='&mobile='+'".$dataarr["mobile"]."';	

							doAjax('record?action=savecomment',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
						}
						else
						{
							alert('Please insert agent comment first');
						}

				}

			</script>     


		</div>
	</div>
</div>
</div>
</div></fieldset>";
return $data;	

}

	//QuestionAire History
function createQaireHistTab()
{
	$user_id = Auth::user()->username;
	$cust_id = $this->recruitdata["peopledata"]["clientcode"];
	$data="";

	$bulkCallID = DB::table("questionaire_details")->where('user_id','=',$user_id)->where('cust_id','=',$cust_id)->orderBy('id','desc')->select('call_id')->distinct()->get();

	dy>
	$custIdArr = array();
	foreach($bulkCallID as $key=> $callID){
		
		$questionAirDetails = DB::table("questionaire_details")->where('user_id','=',$user_id)->where('cust_id','=',$cust_id)->where('call_id','=',$callID->call_id)->select('*')->get();

		$questionAirSortDetails = $questionAirDetails[0];

		$data.="<a onclick='questionAireDiv".$key."()'><div class='panel panel-warning panel-body'>
		<caption><div>
			<div class='col-xs-4'><label class='col-xs-4'>Date/time</label><p class='col-xs-8'>".$questionAirSortDetails->question_time."</p></div>
			<div class='col-xs-4'><label class='col-xs-4'>User ID</label><p class='col-xs-8'>".$questionAirSortDetails->user_id."</p></div>
			<div class='col-xs-4'><label class='col-xs-4'>Mobile</label><p class='col-xs-8'>".$questionAirSortDetails->number."</p></div>
		</div></caption>
		<table class='table table-hover' id='questionAireTable".$key."' style='display:none'>
			<thead>
				<tr><th>Q.No</th>
					<th>Level</th>
					<th>Primary</th>
					<th>Followup1</th>
					<th>Followup2</th>
					<th>Followup3</th>
					<th>Followup4</th>
					<th>Followup5</th>
					<th>Followup6</th>
					<th>Followup7</th>
				</tr>
			</thead><tbody>";

			foreach($questionAirDetails as $keys=> $questionAirDetail){
				if($keys%2==0)
				{
					$data.="<tr style='background-color:#e6e5ef'>";
				}
				else
				{
					$data.="<tr style='background-color:#ffffff'>";
				}		
				$data.="<td>".$questionAirDetail->question."</td>
				<td>Question</td>
				<td>".$questionAirDetail->primary_question."</td>
				<td>".$questionAirDetail->followup1_question."</td>
				<td>".$questionAirDetail->followup2_question."</td>
				<td>".$questionAirDetail->followup3_question."</td>
				<td>".$questionAirDetail->followup4_question."</td>
				<td>".$questionAirDetail->followup5_question."</td>
				<td>".$questionAirDetail->followup6_question."</td>
				<td>".$questionAirDetail->followup7_question."</td>
			</tr>";

			if($keys%2==0)
			{
				$data.="<tr style='background-color:#e6e5ef'>";
			}               
			else
			{
				$data.="<tr style='background-color:#ffffff'>";
			}

			$data.="<td>".$questionAirDetail->question."</td>
			<td>Response</td>
			<td>".$questionAirDetail->primary_response."</td>
			<td>".$questionAirDetail->followup1_response."</td>
			<td>".$questionAirDetail->followup2_response."</td>
			<td>".$questionAirDetail->followup3_response."</td>
			<td>".$questionAirDetail->followup4_response."</td>
			<td>".$questionAirDetail->followup5_response."</td>
			<td>".$questionAirDetail->followup6_response."</td>
			<td>".$questionAirDetail->followup7_response."</td>
		</tr>";

		if($keys%2==0)
		{
			$data.="<tr style='background-color:#e6e5ef'>";
		}               
		else
		{
			$data.="<tr style='background-color:#ffffff'>";
		}

		$data.="<td>".$questionAirDetail->question."</td>
		<td>Text</td>
		<td>".$questionAirDetail->primary_text."</td>
		<td>".$questionAirDetail->followup1_text."</td>
		<td>".$questionAirDetail->followup2_text."</td>
		<td>".$questionAirDetail->followup3_text."</td>
		<td>".$questionAirDetail->followup4_text."</td>
		<td>".$questionAirDetail->followup5_text."</td>
		<td>".$questionAirDetail->followup6_text."</td>
		<td>".$questionAirDetail->followup7_text."</td>
	</tr>";
}

$data.="
</tbody></table></div></a>
<script>
	function questionAireDiv".$key."(){

		var tabStyle".$key." = document.getElementById('questionAireTable".$key."').style.display;		

		if(tabStyle".$key."=='none')
		{
			document.getElementById('questionAireTable".$key."').style.display='block';
		}
		else
		{
			document.getElementById('questionAireTable".$key."').style.display='none';
		}

	}
</script>
";
}

//		$allQuestions = DB::table("questionaire_details")->whereIn('call_id', $custIdArr)->get(); 

return $data;
}

function createCompManage()
{
	$varid=$this->varid;
	$dataarr=$this->recruitdata["peopledata"];
	$callId=1;

	$crmcallDetails=CRMCall::where('crm_id','=',$varid)->orderBy("created_at","DESC")->first();

	if($crmcallDetails)
		$callId = $crmcallDetails->id;

	$compFields = DB::table("complaint_fields")->get();

	$resclassUnitArr = DB::table("complaint_resol_class_unit")->get(); 

	$custType = "<option value=''></option>";
	$custBand = "<option value=''></option>";
	$servType = "<option value=''></option>";
	$priority = "<option value=''></option>";
	$resclassUnit = "<option value=''></option>";
	$rbb = "<option value=''></option>";
	$nonRbb = "<option value=''></option>";
	$cat = "<option value=''></option>";
	$subCat = "<option value=''></option>";
	$srcInfo = "";
	$custCity = "<option value=''></option>";
	$ackSent = "<option value=''></option>";
	$logBranchName = "<option value=''>Select...</option>";
	$logBranchCode = "<option value=''></option>";
	$resBranchCode = "<option value=''></option>";

foreach ($resclassUnitArr as $key => $resclassunit) {
			if($resclassunit->resolve_class_unit)
			$resclassUnit.= "<option value='$resclassunit->id'>$resclassunit->resolve_class_unit</option>";
		}

	foreach ($compFields as $key => $fields) {

		if($fields->cust_type)
			$custType.= "<option value='$fields->cust_type'>$fields->cust_type</option>";

		if($fields->cust_band)
			$custBand.= "<option value='$fields->cust_band'>$fields->cust_band</option>";

		if($fields->service_type)
			$servType.= "<option value='$fields->service_type'>$fields->service_type</option>";

		if($fields->priority)
			$priority.= "<option value='$fields->priority'>$fields->priority</option>";

		if($fields->rbb)
			$rbb.= "<option value='$fields->rbb'>$fields->rbb</option>";

		if($fields->non_rbb)
			$nonRbb.= "<option value='$fields->non_rbb'>$fields->non_rbb</option>";

		if($fields->source_of_info)
			$srcInfo.= "<option value='$fields->source_of_info'>$fields->source_of_info</option>";

		if($fields->cust_city)
			$custCity.= "<option value='$fields->cust_city'>$fields->cust_city</option>";

		if($fields->acknowledge)
			$ackSent.= "<option value='$fields->acknowledge'>$fields->acknowledge</option>";

		if($fields->logging_branch_name)
			$logBranchName.= "<option value='$fields->logging_branch_name'>$fields->logging_branch_name</option>";

		if($fields->logging_branch_code)
			$logBranchCode.= "<option value='$fields->logging_branch_code'>$fields->logging_branch_code</option>";

		if($fields->resolving_branch_code)
			$resBranchCode.= "<option value='$fields->resolving_branch_code'>$fields->resolving_branch_code</option>";

		if($fields->resolving_branch_w_code)
		$resolving_branch_w_code[] = explode("-", $fields->resolving_branch_w_code);

		if($fields->logging_branch_w_code)
		$logging_branch_w_code[] = explode("-", $fields->logging_branch_w_code);

	}

	$resolving_branch_w_code = json_encode($resolving_branch_w_code);
	$logging_branch_w_code = json_encode($logging_branch_w_code);
	$logdate=strtotime(date('Y-m-d H:i:s'))+330*60;

	$data = "
	<style>
		.search {
			position: relative;
		}
		.search .fdg { 
			position:absolute;
	left:10px;
	font-weight:bold;
	font-size:0.8em;
	color:#444;
	top:9px;
		}
	</style>
	<div style='clear:both;margin:2% 0 0 1%;border-style: inset;padding:2%'>
		<h5>Customer Information</h5>
		<hr/><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Complainant Name <span style='color:red;'>*</span></label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='compName' value=''>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>AAN</label>
				<input type='number' class='form_new form_new_amend' style='width:50%;' id='aan'>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Existing Customer<span style='color:red;'>*</span></label>
				<select id='exitCust' class='form_hrm_select select2multi' style='width:50%' readonly>
				<option value='Yes'>Yes</option>
				<option value='No'>No</option>
				</select>
			</div>      
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Upload Date</label>
				<label class='label-small_new' style='width:50%;' >".date('d-m-Y h:i:s A',$logdate)."</label>
			</div>    
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Cust ID<span style='color:red;'>*</span></label>
				<input type='number' class='form_new form_new_amend'style='width:50%;' value='' id='custId'>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Shadow Cust ID</label>
				<input type='number' class='form_new form_new_amend' style='width:50%;' id='shadCustId'>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>CASA FD/RA/DP Number</label>
				<input type='number' class='form_new form_new_amend' style='width:50%;' id='casa'> 
			</div>          

			<div style='width:49%;float:left'  class='search'>
				<label class='label-small_new' style='width:29%;'>Docket Number<span style='color:red;'>*</span></label>
				<input type='text' class='form_new form_new_amend' style='width:52%;' id='dockNum' value=''>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Customer Name On Card</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='custNameOnCard' value=''>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Card Number</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='cardNum' maxlength='16'>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Customer Band</label>
				<select id='custBand' class='form_hrm_select select2multi' style='width:50%'>$custBand</select>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Custmer Type</label>
				<select id='custType' class='form_hrm_select select2multi' style='width:50%;'>$custType</select>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Customer Mobile<span style='color:red;'>*</span></label>
				<input type='number' class='form_new form_new_amend' style='width:50%;' id='custMob' maxlength='10'>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Contact Number</label>
				<input type='number' class='form_new form_new_amend' style='width:50%;' id='contNum'>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Email</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='email' value='' maxlength='50'>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Case Reference</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='caseRef' value='' maxlength='50'>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Source Of Information<span style='color:red;'>*</span></label>
				<select id='srcInfo' class='form_hrm_select select2multi' style='width:50%'>$srcInfo</select>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Customer City</label>
				<select id='custCity' class='form_hrm_select select2multi' style='width:50%;'>$custCity</select>
			</div>  
		</div>
		<br><br><br>

		<h5>Case Information</h5>
		<hr/>
		<br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Service Type</label>
				<select id='serveType' class='form_hrm_select select2multi' style='width:50%'>$servType</select>
			</div> 
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Priority</label>
				<select id='prior' class='form_hrm_select select2multi' style='width:50%'>$priority</select>
			</div>                  	 
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Logging Branch Name<span style='color:red;'>*</span></label>
				<select id='logBranchName' class='form_hrm_select select2multi' style='width:50%' readonly>$logBranchName</select>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Logging Classification Unit<span style='color:red;'>*</span></label>
				<select id='logClassUnit' class='form_hrm_select select2multi' style='width:50%' readonly>
				<option value=''></option>
				<option value='COP'>COP</option>
				<option value='PRIME'>PRIME</option>
				</select>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Logging Branch Code</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='logBranchCode' value='' readonly>
			</div> 

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Acknowledge Sent</label>
				<select id='ackSent' class='form_hrm_select select2multi' style='width:50%'>$ackSent</select>
			</div>  
		</div>
		<br><br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left' class='search'>
				<label class='label-small_new' style='width:29%;'>Proposed/Resolving Classification Unit</label>
				<select id='resclassUnit' class='form_hrm_select select2multi' style='width:50%'>$resclassUnit</select>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Resolving Branch Code</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='resBranchCode' value='' readonly>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Proposed/Resolving Branch Name<span style='color:red;'>*</span></label>
				<select id='resBranch' class='form_hrm_select select2multi' style='width:50%'></select>
			</div>  
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Status</label>
				<select id='compStatus' class='form_hrm_select select2multi' style='width:50%'>
				<option value='Open'>Open</option>
				<option value='Close'>Close</option>
				</select>
			</div> 
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Category<span style='color:red;'>*</span></label>
				<select id='cat' class='form_hrm_select select2multi' style='width:50%'></select>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Subcategory<span style='color:red;'>*</span></label>
				<select id='subCat' class='form_hrm_select select2multi' style='width:50%'> </select>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Additional Information</label>
				<textarea class='form_new form_new_amend'style='width:74%;' maxlength='1000' id='addInfo' rows='8'></textarea>
				<p id='addInfoText' style='margin-left:14%;'></p>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Nature Of Complaint<span style='color:red;'>*</span></label>
				<textarea class='form_new form_new_amend'style='width:74%;border-left: 3px solid #FF4500;' maxlength='512' id='noc' rows='4'></textarea>
				<p id='nocText' style='margin-left:14%;'></p>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Detailed Suggestion</label>
				<textarea class='form_new form_new_amend'style='width:74%;' maxlength='512' id='detailSuggest' rows='4'></textarea>
				<p id='detailSuggestText' style='margin-left:14%;'></p>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<input type='button' class='btn btn-default btn-md' style='margin-left:40%' value='Save' id='save'>        
		</div>
	</div>

	<script>

		var addInfotext_max = 1000-$('#addInfo').val().length;
		$('#addInfoText').html(addInfotext_max + ' chars remaining');

		$('#addInfo').keyup(function() {
			var addInfotext_length = $('#addInfo').val().length;
			var addInfotext_remaining = addInfotext_max - addInfotext_length;

			$('#addInfoText').html(addInfotext_remaining + ' chars remaining');
		});

		var noctext_max = 512-$('#noc').val().length;
		$('#nocText').html(noctext_max + ' chars remaining');

		$('#noc').keyup(function() {
			var noctext_length = $('#noc').val().length;
			var noctext_remaining = noctext_max - noctext_length;

			$('#nocText').html(noctext_remaining + ' chars remaining');
		});

		var detailSuggesttext_max = 512-$('#detailSuggest').val().length;
		$('#detailSuggestText').html(detailSuggesttext_max + ' chars remaining');

		$('#detailSuggest').keyup(function() {
			var detailSuggesttext_length = $('#detailSuggest').val().length;
			var detailSuggesttext_remaining = detailSuggesttext_max - detailSuggesttext_length;

			$('#detailSuggestText').html(detailSuggesttext_remaining + ' chars remaining');
		});

		$('#logBranchName').click(function()
		{
			var logBranchName = $(this).val();
			var logging_branch_w_code = $logging_branch_w_code;

			if(logBranchName)
			{
				for(var l in logging_branch_w_code)
				{
					if((logging_branch_w_code[l][0]).trim() === logBranchName)
					{
						$('#logBranchCode').val(logging_branch_w_code[l].pop());
					}
				}
			}
			else
			{
				$('#logBranchCode').val('');
			}
		});

		$('#resBranch').click(function()
		{
			var resBranchVal = $(this).val();
			var resolving_branch_w_code = $resolving_branch_w_code;

			for(var lb in resolving_branch_w_code)
			{
				if((resolving_branch_w_code[lb][0]).trim()==resBranchVal)
				{
					$('#resBranchCode').val(resolving_branch_w_code[lb].pop());
				}
			}
		});

		$('#resclassUnit').click(function()
		{ 
			var resclassUnitVal = $(this).val();

			//To make empty when Non rbb selected
			$('#resBranchCode').val('');
			$('#resBranch').select2('val', '');

			if(resclassUnitVal)
			{
				doAjax('resclassUnit','resclassUnitVal='+encodeURIComponent(resclassUnitVal),'','','singlethis','POST',function(retstr){
					var compArr = JSON.parse(retstr.responseText);
					$('#resBranch').empty();

					if(resclassUnitVal == '19')
					{
						$('#resBranch').append(\"<option value=''>Select...</option>\");

						for(var i in compArr)
						{
							$('#resBranch').append(\"<option value='\"+compArr[i]['rbb']+\"'>\"+compArr[i]['rbb']+\"</option>\");
						}
					}

					if(resclassUnitVal != '19')
					{
						for(var i in compArr)
						{
							$('#resBranch').append(\"<option value='\"+compArr[i]['non_rbb']+\"'>\"+compArr[i]['non_rbb']+\"</option>\");
						}
					}

				});

				var action = 'category/'+resclassUnitVal;

				$('#cat').select2('val', '');
				$('#cat').html('');
				$('#subCat').select2('val', '');
				$('#subCat').html('');

				$.ajax({
					type: 'get',
					url: action,
					data: resclassUnitVal,
					success: function(nextRecord)
					{
						var catArr = nextRecord['category'];

						$('#cat').append(\"<option value=''>Select Category</option>\");

						for(var i in catArr)
						{
							$('#cat').append(\"<option value='\"+catArr[i]['id']+\"~\"+catArr[i]['category']+\"'>\"+catArr[i]['category']+\"</option>\");
						}

						
					}
				});

			}
		});

		$('#cat').click(function()
		{ 
			var catidsplit = $(this).val();
			var categoryval = catidsplit.split('~');
			catId = categoryval[0];
			categoryvalue = categoryval[1];

			var resclassUnitVal = $('#resclassUnit').val();

			//To make empty when Non rbb selected
			$('#subCat').select2('val', '');

			if(catId)
			{
				var action = 'subcategory/'+catId+'/'+resclassUnitVal;

				$('#subCat').html('');

				$.ajax({
					type: 'get',
					url: action,
					data: catId,
					success: function(nextRecord)
					{
						var subCatArr = nextRecord['sub_category'];

						$('#subCat').append(\"<option value=''>Select SubCategory</option>\");

						for(var i in subCatArr)
						{
							$('#subCat').append(\"<option value='\"+subCatArr[i]+\"'>\"+subCatArr[i]+\"</option>\");
						}
						
					}
				});
			}

		});

 	//To save all details
		$('#save').click(function()
		{ 
			var compName = $('#compName').val();
			var aan = $('#aan').val();
			var exitCust = $('#exitCust').val();
			var custId = $('#custId').val();
			var shadCustId = $('#shadCustId').val();
			var casa = $('#casa').val();
			var dockNum = $('#dockNum').val();
			var custNameOnCard = $('#custNameOnCard').val();
			var cardNum = $('#cardNum').val();
			var custBand = $('#custBand').val();
			var custCity = $('#custCity').val();
			var custType = $('#custType').val();
			var custMob = $('#custMob').val();
			var contNum = $('#contNum').val();
			var email = $('#email').val();
			var caseRef = $('#caseRef').val();
			var srcInfo = $('#srcInfo').val();
			var custCity = $('#custCity').val();
			var serveType = $('#serveType').val();
			var priority = $('#prior').val();
			var logBranchName = $('#logBranchName').val();
			var logClassUnit = $('#logClassUnit').val();
			var ackSent = $('#ackSent').val();
			var resclassUnit = $('#resclassUnit').val();
			var resBranch = $('#resBranch').val();
			var cat = $('#cat').val();
			
            
			var subCat = $('#subCat').val();
			var addInfo = $('#addInfo').val();
			var noc = $('#noc').val();
			var detailSuggest = $('#detailSuggest').val();
			var logBranchCode = $('#logBranchCode').val();
			var resBranchCode = $('#resBranchCode').val();
			var compStatus = $('#compStatus').val();
			var call_id = ".$callId.";
			

			
            if(compName==''){
            	simpleNotification('error','topRight','please enter Complainant Name');
            	return;
            }else if(exitCust==''){
            	simpleNotification('error','topRight','please select existing Customer');
            	return;
            }else if(custId==''){
            	simpleNotification('error','topRight','please enter Customer Id');
            	return;
            }else if(dockNum==''){
            	simpleNotification('error','topRight','please enter Docket Number');
            	return;
            }else if(custMob==''){
            	simpleNotification('error','topRight','please enter Customer Mobile');
            	return;
            }else if(logBranchName==''){
            	simpleNotification('error','topRight','please select Logging Branch Name');
            	return;
            }else if(logClassUnit==''){
            	simpleNotification('error','topRight','please select Logging Classification Unit');
            	return;
            }else if(resBranch==''){
            	simpleNotification('error','topRight','please select Resolving Branch Name');
            	return;
            }else if(cat==''){
            	simpleNotification('error','topRight','please select Category');
            	return;
            }else if(subCat==''){
            	simpleNotification('error','topRight','please select Subcategory');
            	return;
            }else if(srcInfo==''){
            	simpleNotification('error','topRight','please select Source Of Information');
            	return;
            }else if(noc==''){
            	simpleNotification('error','topRight','please enter Nature Of Complaint');
            	return;
            }

			if(isNaN(cardNum))
			{
				swal('Please enter proper Card Number');
				return;
			}
            var category = cat.split('~');
			var catId = category[0];
			var categoryvalue = category[1];
			
			var postdata='complainant_name='+encodeURIComponent(compName);
			postdata+='&aan='+encodeURIComponent(aan);
			postdata+='&existing_customer='+encodeURIComponent(exitCust);
			postdata+='&cust_id='+encodeURIComponent(custId);
			postdata+='&shadow_cust_id='+encodeURIComponent(shadCustId);
			postdata+='&casa_number='+encodeURIComponent(casa);
			postdata+='&docket_number='+encodeURIComponent(dockNum);
			postdata+='&cust_name_on_card='+encodeURIComponent(custNameOnCard);
			postdata+='&card_number='+encodeURIComponent(cardNum);
			postdata+='&cust_band='+encodeURIComponent(custBand);
			postdata+='&cust_city='+encodeURIComponent(custCity);
			postdata+='&cust_type='+encodeURIComponent(custType);
			postdata+='&cust_mobile='+encodeURIComponent(custMob);
			postdata+='&contact_number='+encodeURIComponent(contNum);
			postdata+='&email='+encodeURIComponent(email);
			postdata+='&case_reference='+encodeURIComponent(caseRef);
			postdata+='&source_of_info='+encodeURIComponent(srcInfo);
			postdata+='&cust_city='+encodeURIComponent(custCity);
			postdata+='&service_type='+encodeURIComponent(serveType);
			postdata+='&priority='+encodeURIComponent(priority);
			postdata+='&acknowledge='+encodeURIComponent(ackSent);
			postdata+='&logging_branch_name='+encodeURIComponent(logBranchName);
			postdata+='&logging_class_unit='+encodeURIComponent(logClassUnit);
			postdata+='&resolve_class_unit='+encodeURIComponent(resclassUnit);
			postdata+='&resolving_branch='+encodeURIComponent(resBranch);
			postdata+='&category='+encodeURIComponent(categoryvalue);
			postdata+='&sub_category='+encodeURIComponent(subCat);
			postdata+='&additional_info='+encodeURIComponent(addInfo);
			postdata+='&nature_of_complaint='+encodeURIComponent(noc);
			postdata+='&detailed_suggestion='+encodeURIComponent(detailSuggest);
			postdata+='&logging_branch_code='+encodeURIComponent(logBranchCode);
			postdata+='&resolving_branch_code='+encodeURIComponent(resBranchCode);
			postdata+='&status='+encodeURIComponent(compStatus);
			postdata+='&call_id='+encodeURIComponent(call_id);
			doAjax('complaint',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
		});
	</script>
	";
	
	return $data;
}

function createChildCase()
{
	$callId=0;
	$varid=$this->varid;
	$dataarr=$this->recruitdata["peopledata"];

	$resclassUnit = "<option value=''></option>";
	$cat = "<option value=''></option>";
	$subCat = "<option value=''></option>";

	$resclassUnitArr = DB::table("complaint_resol_class_unit")->get();

	foreach ($resclassUnitArr as $key => $resclassunit) {
			if($resclassunit->resolve_class_unit)
			$resclassUnit.= "<option value='$resclassunit->id'>$resclassunit->resolve_class_unit</option>";
		}


	$data = "
	<style>
		.search {
			position: relative;
		}
		.search .fdg { 
			position:absolute;
	left:10px;
	font-weight:bold;
	font-size:0.8em;
	color:#444;
	top:9px;
		}
	</style>
	<div style='clear:both;margin:2% 0 0 1%;border-style: inset;padding:2%'>
		<h5>Key Information</h5>
		<hr/><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Complainant Name</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='ccompName' value='".$dataarr['firstname']."'>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Custmer Type</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='ccustType' value='".$compDetails->cust_type."' readonly>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Status</label>
				<select id='ccompStatus' class='form_hrm_select select2multi' style='width:50%'>
				<option value='Open'>Open</option>
				<option value='Close'>Close</option>
				</select>
			</div>      
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Service Type</label>
				<select id='cserveType' class='form_hrm_select select2multi' style='width:50%'>
				<option value>Select Value</option>
				<option value='Query'>Query</option>
				<option value='Complaint'>Complaint</option>
				<option value='Request'>Request</option>
				</select>
			</div>    
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Priority</label>
				<select id='cprior' class='form_hrm_select select2multi' style='width:50%'>
				<option value='High'>High</option>
				<option value='Normal'>Normal</option>
				</select>
			</div>          
  
		</div>
		<br><br><br>
		<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left' class='search'>
				<label class='label-small_new' style='width:29%;'>Resolving Classification Unit</label>
				<select id='cresclassUnit' class='form_hrm_select select2multi' style='width:50%'>$resclassUnit</select>
			</div>          

			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Resolving Branch</label>
				<select id='cresBranch' class='form_hrm_select select2multi' style='width:50%'></select>
			</div>  
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Category</label>
				<select id='ccat' class='form_hrm_select select2multi' style='width:50%'></select>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Subcategory</label>
				<select id='csubCat' class='form_hrm_select select2multi' style='width:50%'></select>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Additional Information</label>
				<textarea class='form_new form_new_amend'style='width:74%;' maxlength='1000' id='caddInfo' rows='8'></textarea>
				<p id='caddInfoText' style='margin-left:14%;'></p>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Task Description</label>
				<textarea class='form_new form_new_amend'style='width:74%;border-left: 3px solid #FF4500;' maxlength='512' id='ctaskDesc' rows='4'></textarea>
				<p id='ctaskDescText' style='margin-left:14%;'></p>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<div>
				<label class='label-small_new' style='width:14%;'>Comments</label>
				<textarea class='form_new form_new_amend'style='width:74%;' maxlength='512' id='comments' rows='4'></textarea>
				<p id='commentsText' style='margin-left:14%;'></p>
			</div>          
		</div>
		<br><br>
		<div style='clear:both;width:100%;'>
			<input type='button' class='btn btn-default btn-md' style='margin-left:40%' value='Save' id='Save'>        
		</div>
	</div>

	<script>

		var addInfotext_max = 1000-$('#caddInfo').val().length;
		$('#caddInfoText').html(addInfotext_max + ' chars remaining');

		$('#caddInfo').keyup(function() {
			var addInfotext_length = $('#caddInfo').val().length;
			var addInfotext_remaining = addInfotext_max - addInfotext_length;

			$('#caddInfoText').html(addInfotext_remaining + ' chars remaining');
		});

		var taskDesctext_max = 512-$('#ctaskDesc').val().length;
		$('#ctaskDescText').html(taskDesctext_max + ' chars remaining');

		$('#ctaskDesc').keyup(function() {
			var taskDesctext_length = $('#ctaskDesc').val().length;
			var taskDesctext_remaining = taskDesctext_max - taskDesctext_length;

			$('#ctaskDescText').html(taskDesctext_remaining + ' chars remaining');
		});

		var commentstext_max = 512-$('#comments').val().length;
		$('#commentsText').html(commentstext_max + ' chars remaining');

		$('#comments').keyup(function() {
			var commentstext_length = $('#comments').val().length;
			var commentstext_remaining = commentstext_max - commentstext_length;

			$('#commentsText').html(commentstext_remaining + ' chars remaining');
		});

		$('#cresclassUnit').click(function()
		{ 
			var resclassUnitVal = $(this).val();

			//To make empty when Non rbb selected
			$('#cresBranch').select2('val', '');

			if(resclassUnitVal)
			{
				doAjax('resclassUnit','resclassUnitVal='+encodeURIComponent(resclassUnitVal),'','','singlethis','POST',function(retstr){
					var compArr = JSON.parse(retstr.responseText);
					$('#cresBranch').empty();

					if(resclassUnitVal == '19')
					{
						$('#cresBranch').append(\"<option value=''>Select...</option>\");

						for(var i in compArr)
						{
							$('#cresBranch').append(\"<option value='\"+compArr[i]['rbb']+\"'>\"+compArr[i]['rbb']+\"</option>\");
						}
					}

					if(resclassUnitVal != '19')
					{
						for(var i in compArr)
						{
							$('#cresBranch').append(\"<option value='\"+compArr[i]['non_rbb']+\"'>\"+compArr[i]['non_rbb']+\"</option>\");
						}
					}

				});

				var action = 'category/'+resclassUnitVal;

				$('#ccat').select2('val', '');
				$('#ccat').html('');
				$('#csubCat').select2('val', '');
				$('#csubCat').html('');

				$.ajax({
					type: 'get',
					url: action,
					data: resclassUnitVal,
					success: function(nextRecord)
					{
						var catArr = nextRecord['category'];

						$('#ccat').append(\"<option value=''>Select Category</option>\");

						for(var i in catArr)
						{
							$('#ccat').append(\"<option value='\"+catArr[i]['id']+\"'>\"+catArr[i]['category']+\"</option>\");
						}

						
					}
				});

			}
		});

		$('#ccat').click(function()
		{ 
			var catId = $(this).val();

			//To make empty when Non rbb selected
			$('#csubCat').select2('val', '');

			if(catId)
			{
				var action = 'subcategory/'+catId;

				$('#subCat').html('');

				$.ajax({
					type: 'get',
					url: action,
					data: catId,
					success: function(nextRecord)
					{
						var subCatArr = nextRecord['sub_category'];

						$('#csubCat').append(\"<option value=''>Select SubCategory</option>\");

						for(var i in subCatArr)
						{
							$('#csubCat').append(\"<option value='\"+subCatArr[i]+\"'>\"+subCatArr[i]+\"</option>\");
						}
						
					}
				});
			}

		});

 	//To save all details
		$('#Save').click(function()
		{ 
			var compName = $('#ccompName').val();
			var custType = $('#ccustType').val();
			var serveType = $('#cserveType').val();
			var priority = $('#cprior').val();
			var resclassUnit = $('#cresclassUnit').val();
			var resBranch = $('#cresBranch').val();
			var cat = $('#ccat').val();
			var subCat = $('#csubCat').val();
			var addInfo = $('#caddInfo').val();
			var taskDesc = $('#ctaskDesc').val();
			var compStatus = $('#ccompStatus').val();
			var comments = $('#comments').val();
			var varid = '".$varid."';

			if(compName==''||resBranch==''||cat==''||subCat==''||taskDesc=='')
			{
				alert('Complainant Name,Resolving Branch Name,Category,Subcategory,Task Description');
				return;
			}

			var postdata='complainant_name='+encodeURIComponent(compName);
			postdata+='&cust_type='+encodeURIComponent(custType);
			postdata+='&service_type='+encodeURIComponent(serveType);
			postdata+='&priority='+encodeURIComponent(priority);
			postdata+='&resolve_class_unit='+encodeURIComponent(resclassUnit);
			postdata+='&resolving_branch='+encodeURIComponent(resBranch);
			postdata+='&category='+encodeURIComponent(cat);
			postdata+='&sub_category='+encodeURIComponent(subCat);
			postdata+='&additional_info='+encodeURIComponent(addInfo);
			postdata+='&task_desc='+encodeURIComponent(taskDesc);
			postdata+='&comments='+encodeURIComponent(comments);
			postdata+='&status='+encodeURIComponent(compStatus);
			postdata+='&varid='+encodeURIComponent(varid);
			doAjax('childcase',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
		});
	</script>
	";

		return $data;
}
//Function for lead form creation by Gopal
function createLeadEntryForm()
{		$leadFormProducts = DB::table("leadform_products")->get();
        $dataarr=$this->recruitdata["peopledata"];
		$products = "<option value=''></option>";
			foreach ($leadFormProducts as $key => $fields) 
			{
			if($fields->products)
			$products.= "<option value='$fields->products'>$fields->products</option>";
			}
		$branchcodeMaster=DB::table("UD_CRM_BR_MASTER")->select('BR_CODE','BR_NAME')->get();
		$brcode = "<option value=''></option>";
		$brname = "<option value=''></option>";
		foreach ($branchcodeMaster as $key => $brmaster) 
		{
			if($brmaster->BR_CODE)
			$brcode.= "<option value='$brmaster->BR_CODE'>$brmaster->BR_CODE</option>";
		    if($brmaster->BR_NAME)
		    $brname.= "<option value='$brmaster->BR_CODE'>$brmaster->BR_NAME</option>";
		}
		$sm_master=	DB::table("UD_SM_MAPPING")->select(DB::raw('distinct USER_NAME'))->where('USER_NAME','!=','')->get();
		$smname="<option value=''></option>";
		foreach ($sm_master as $key => $sm_name) 
		{
			if($sm_name->USER_NAME)
			$smname.= "<option value='$sm_name->USER_NAME'>$sm_name->USER_NAME</option>";
		}
		$cust_profile=	DB::table("UD_LEAD_ENTRY_CUSTOMER_PROFILE")->select('CUST_PROFILE')->get();	
		$custprofile="<option value=''></option>";
		foreach ($cust_profile as $key => $cust_pro) {
			$custprofile.="<option value='$cust_pro->CUST_PROFILE'>$cust_pro->CUST_PROFILE</option>";
		}
		$dataarr=$this->recruitdata["peopledata"];
			$data="<div style='clear:both;margin:2% 0 0 1%;border-style: dotted solid dashed;padding:2%'>
			<h5>Lead Entry Form</h5>
			<hr/><br>

			<div style='clear:both;width:100%;'>
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Customer Name</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;border: 2px solid;' value='".$dataarr['firstname']."' id='customer_name' readonly>
				</div>
			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				 <div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Branch Name</label>
					<select  class='form_hrm_select select2multi' style='width:50%;border: 2px solid;' id='br_name'>$brname</select>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>LG Code</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;border: 2px solid;' value='' id='lg_code'>
				</div>
			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				 <div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Mobile Number</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;border: 2px solid;' value='".$dataarr['mobile']."' id='mobile'>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Processing entity</label>
					<select  class='form_hrm_select select2multi' style='width:50%;border: 2px solid;' id='processing_entity'><option value='SALES'>SALES</option><option value='OCC'>OCC</option></select>
				</div>
			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				 <div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Lead Owner</label>
					<select  class='form_hrm_select select2multi' style='width:50%;border: 2px solid;' id='lead_owner'>$smname</select>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Lead Priority</label>
					<select  class='form_hrm_select select2multi' style='width:50%;border: 2px solid;' id='lead_priority'><option value='Urgent'>Urgent</option><option value='Normal'>Normal</option></select>
				</div>
			</div>
			<br><br>	
			<div style='clear:both;width:100%;'>
				 <div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Product</label>
					<select  class='form_hrm_select select2multi' style='width:50%;border: 2px solid;' id='product'>$products</select>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;font-weight:bold;'>Customer Profile</label>
					<select  class='form_hrm_select select2multi' style='width:50%;border: 2px solid;' id='customer_profile'>$custprofile</select>
				</div> 
			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				<div>
					<label class='label-small_new' style='width:14%;font-weight:bold;'>Remarks</label>
					<textarea class='form_new form_new_amend'style='width:74%;border: 2px solid;' maxlength='512' id='remarks' rows='4'></textarea>
				</div>          
			</div>
		<br><br>
			<div style='clear:both;width:100%;'>
				<input type='button' class='btn btn-default btn-md' style='margin-left:40%;font-weight:bold;' value='Save' id='leadformSave'>        
			</div>
		</div>
	
<script>



			$('#leadformSave').click(function()
			{ 
				if(kstychCall['ts_Talk']<1||Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000))<10)
				{		
					simpleNotification('error','topRight','please get On call first');
					$('#br_name').select2('data', {id:'', text:''});
                    $('#lg_code').val('');
                    $('#processing_entity').select2('data', {id:'', text:''});
					$('#lead_owner').select2('data', {id:'', text:''});
					$('#lead_priority').select2('data', {id:'', text:''});
					$('#product').select2('data', {id:'', text:''});
					$('#customer_profile').select2('data', {id:'', text:''});
					$('#remarks').val('');
					return;	
				}
				else
				{
					var br_code = $('#br_name').val();
					var br_name=  $('#br_name option:selected').text();
					var lg_code = $('#lg_code').val();
					var mobile = $('#mobile').val();
					var processing_entity = $('#processing_entity').val();
					var lead_owner = $('#lead_owner').val();
					var lead_priority = $('#lead_priority').val();
					var product = $('#product').val();
					var customer_profile = $('#customer_profile').val();
					var remarks = $('#remarks').val();
					
					if(br_name==''){
	            		simpleNotification('error','topRight','please select Branch Name');
	            		return;
	            	}else if(lg_code==''){
	            		simpleNotification('error','topRight','please enter LG Code');
	            		return;
	            	}else if(mobile==''){
	            		simpleNotification('error','topRight','please enter Mobile Number');
	            		return;
	            	}else if(processing_entity==''){
	            		simpleNotification('error','topRight','please select Processing Entity');
	            		return;
	            	}else if(lead_owner==''){
	            		simpleNotification('error','topRight','please Select lead owner');
	            		return;
	            	}else if(lead_priority==''){
	            		simpleNotification('error','topRight','please select lead Priority');
	            		return;
	            	}else if(product==''){
	            		simpleNotification('error','topRight','please select Product');
	            	return;
	            	}else if(customer_profile==''){
	            		simpleNotification('error','topRight','please select Customer Profile');
	            		return;
	            	}else if(remarks==''){
	            		simpleNotification('error','topRight','please select Remarks');
	            		return;
	            	}
					
                    $('#br_name').select2('data', {id:'', text:''});
                    $('#lg_code').val('');
                    $('#processing_entity').select2('data', {id:'', text:''});
					$('#lead_owner').select2('data', {id:'', text:''});
					$('#lead_priority').select2('data', {id:'', text:''});
					$('#product').select2('data', {id:'', text:''});
					$('#customer_profile').select2('data', {id:'', text:''});
					$('#remarks').val('');
					
					var postdata='varid='+$('#varid').val();
					postdata+='&mobile='+'".$dataarr["mobile"]."';
					postdata+='&client='+'".$dataarr["client"]."';
					postdata+='&clientcode='+'".$dataarr["clientcode"]."';
					postdata+='&firstname='+'".$dataarr["firstname"]."';
					postdata+='&br_code='+encodeURIComponent(br_code);
					postdata+='&br_name='+encodeURIComponent(br_name);
					postdata+='&lg_code='+encodeURIComponent(lg_code);
					postdata+='&processing_entity='+encodeURIComponent(processing_entity);
					postdata+='&lead_owner='+encodeURIComponent(lead_owner);
					postdata+='&lead_priority='+encodeURIComponent(lead_priority);
					postdata+='&product='+encodeURIComponent(product);
					postdata+='&customer_profile='+encodeURIComponent(customer_profile);
					postdata+='&remarks='+encodeURIComponent(remarks);
					
					
					
					doAjax('leadentryform',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
				}	
				
		});

				</script>
		";

		return $data;

}
function createRacingCust()
{
	$dataarr=$this->recruitdata["peopledata"];

	$data="<div style='clear:both;margin:2% 0 0 1%;border-style: dotted solid dashed;padding:2%'>
			<h5>Customer Information</h5>
			<hr/><br>
				<br><br>
				<div style='clear:both;width:100%;'>
					<div style='width:49%;float:left'>
                                        <label class='label-small_new' style='width:29%;'>Date</label>
                                        <label class='label-small_new' style='width:50%;' >".date('Y-m-d')."</label>
					</div>
				<br><br>

				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>PB Code</label>
					<input type='text' class='form_new form_new_amend'style='width:50%;' value='' id='PBcode'>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>PB Name</label>
					<input type='text' class='form_new form_new_amend'style='width:50%;' value='' id='PBname'>
				</div> 

			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>PB landline Contact No.</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='PBlandlineContNo'>
				</div> 
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Supervisor Mail ID</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='SupervisormailID'> 
				</div>

			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				
				<div style='width:49%;float:left'  class='search'>
					<label class='label-small_new' style='width:29%;'>Group ID</label>
					<input type='text' class='form_new form_new_amend' style='width:52%;' id='groupID' value=''>
				</div> 
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Group ID Name</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='groupidname' value=''>
				</div>  

			</div>
			<br><br>
			<div style='clear:both;width:100%;'>

				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Cust ID</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='custID' maxlength='16'>
				</div>
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Cust Name</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='custname' value=''>
				</div>  

			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Relationship With Group ID</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='RelationshipGroupID' maxlength='16'>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Cust ID</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='Custid' maxlength='16'>
				</div>

			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Cust Name</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='CustName' value=''>
				</div>  
				<div style='width:49%;float:left'>
					<label class='label-small_new' style='width:29%;'>Relationship With Group ID</label>
					<input type='text' class='form_new form_new_amend' style='width:50%;' id='relationshipgroupid' maxlength='16'>
				</div>  

			</div>
			<br><br>
			<div style='clear:both;width:100%;'>
			<div style='width:49%;float:left'>

				<label class='label-small_new' style='width:29%;'>Grouping</label>
                                <select id='newGroupdditiongroup' class='form_hrm_select select2multi' style='width:50%'>
                                <option value='New_Group'>New Group</option>
                                <option value='Addition_to_group'>Addition to group</option>
				<option value='Addition_to_group'>Regroup</option>
				</select>

			</div>  
			<div style='width:49%;float:left'>
				<label class='label-small_new' style='width:29%;'>Racing from</label>
				<input type='text' class='form_new form_new_amend' style='width:50%;' id='racingfrom'>
			</div>  
			</div>
			<br><br><br>


			<br><br>
			<div style='clear:both;width:100%;'>
				<input type='button' class='btn btn-default btn-md' style='margin-left:40%' value='Save' id='CRSave'>        
			</div>
		</div>

		<script>



			$('#CRSave').click(function()
			{ 
				var snumber = $('#snumber').val();
				var PBname = $('#PBname').val();
				var PBcode = $('#PBcode').val();
				var PBlandlineContNo = $('#PBlandlineContNo').val();
				var SupervisormailID = $('#SupervisormailID').val();
				var groupID = $('#groupID').val();
				var groupidname = $('#groupidname').val();
				var custID = $('#custID').val();
				var custname = $('#custname').val();
				var RelationshipGroupID = $('#RelationshipGroupID').val();
				var Custid = $('#Custid').val();
				var CustName = $('#CustName').val();
				var relationshipgroupid = $('#relationshipgroupid').val();
				var newGroupdditiongroup = $('#newGroupdditiongroup').val();
				var racingfrom = $('#racingfrom').val();

				var postdata='s_no='+encodeURIComponent(snumber);
				postdata+='&pb_name='+encodeURIComponent(PBname);
				postdata+='&pb_code='+encodeURIComponent(PBcode);
				postdata+='&pb_landline_contact_no='+encodeURIComponent(PBlandlineContNo);
				postdata+='&supervisor_mail_id='+encodeURIComponent(SupervisormailID);
				postdata+='&group_id='+encodeURIComponent(groupID);
				postdata+='&group_id_name='+encodeURIComponent(groupidname);
				postdata+='&cust_id='+encodeURIComponent(custID);
				postdata+='&cust_name='+encodeURIComponent(custname);
				postdata+='&relationship_with_group_id='+encodeURIComponent(RelationshipGroupID);
				postdata+='&cust_id_next='+encodeURIComponent(Custid);
				postdata+='&cust_name_next='+encodeURIComponent(CustName);
				postdata+='&relationship_with_group_id_next='+encodeURIComponent(relationshipgroupid);
				postdata+='&new_group_addition_to_group='+encodeURIComponent(newGroupdditiongroup);
				postdata+='&racing_from='+encodeURIComponent(racingfrom);
				postdata+='&mobile='+'".$dataarr["mobile"]."';
				postdata+='&client='+'".$dataarr["client"]."';
				postdata+='&clientcode='+'".$dataarr["clientcode"]."';

				doAjax('custrace',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
		});

				</script>";

				return $data;
}
//for RLP
function createRLP()
{
    $dataarr=$this->recruitdata["peopledata"];
    $rlpcust = DB::table('p11086_cop_rlp_cust_base_uat')->where('pbcode','=',$dataarr["client"])->where('cod_cust','=',$dataarr["clientcode"])->select('*')->get();
    $data="";
    //echo "<pre>".print_r($rlpcust)."</pre>";
    $data.="<fieldset><legend class='new-recruit_legend'>RLP Customer WISE</legend>";

	        $data.="<div class=custom1 style='width:100%;'>
	        <h2></h2>";

	        $data.="<hr><br><table class='table kDataTable' cellpadding=0 cellspacing=0 border=0>
	        	<thead><tr>
	            <td class='table_hrm_heading_green'>Product</td>
	            <td class='table_hrm_heading_green'>Opportunity</td>
	            <td class='table_hrm_heading_green'>Contacted</td>
	            <td class='table_hrm_heading_green'>Total Unique Calls Made to customer with Opportunity </td>
	            <td class='table_hrm_heading_green'>Total Unique Customers Pitched</td>
	            <td class='table_hrm_heading_green'>LG (Offline)</td>
	            <td class='table_hrm_heading_green'>LC</td>
	            <td class='table_hrm_heading_green'>Activation</td>
	        </tr></thead>";
     $data.="<tr>
	            <td>Auto Loan</td>
	            <td>
	            <table>
	            <tr><td>".$rlpcust[0]->al_qm_opp."</td></tr><tr><td>".$rlpcust[0]->al_upg_opp."</td></tr><tr><td>".$rlpcust[0]->al_al_cnc_opp."</td></tr><tr><td>".$rlpcust[0]->al_pa_opp."</td></tr><tr><td>".$rlpcust[0]->al_zip_opp."</td></tr></table>
	            </td>
	            <td>".$rlpcust[0]->al_called_opp."</td>
	            <td>".$rlpcust[0]->al_pitch."</td>
	            <td></td>
	            <td>".$rlpcust[0]->al_lg."</td>
	            <td></td>
	            <td></td>
	         </tr>
	         <tr>
	            <td>Personal Loan</td>
	            <td>
	            <table>
	            <tr><td>".$rlpcust[0]->pl_10sec_opp."</td></tr><tr><td>".$rlpcust[0]->pl_pa_opp."</td></tr><tr><td>".$rlpcust[0]->pl_pq_opp."</td></tr><tr><td>".$rlpcust[0]->bl_10sec_opp."</td></tr><tr><td>".$rlpcust[0]->bl_pq_opp."</td></tr>
	            </table>
	            </td>
	            <td>".$rlpcust[0]->pl_called_opp."</td>
	            <td>".$rlpcust[0]->pl_pitch."</td>
	            <td></td>
	            <td>".$rlpcust[0]->pl_lg."</td>
	            <td></td>
	            <td></td>
	         </tr>
	         <tr>
	         	<td>Two Wheeler Loan</td>
	         	<td>".$rlpcust[0]->twl_pa_opp."</td>
	         	<td>".$rlpcust[0]->twl_called_opp."</td>
	         	<td>".$rlpcust[0]->twl_pitch."</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->twl_lg."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Home Loan</td>
	         	<td>
	         	<table>
	         	<tr><td>".$rlpcust[0]->hl_pq_opp."<td></tr><tr><td>".$rlpcust[0]->hl_bt_opp."<td></tr>
	         	</table>
	         	</td>
	         	<td>".$rlpcust[0]->hl_called_opp."</td>
	         	<td>".$rlpcust[0]->hl_pitch."</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->hl_pitch."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Gold Loan</td>
	         	<td>GL</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->gl_pitch."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Loan Against Securities</td>
	         	<td>".$rlpcust[0]->las_opp."</td>
	         	<td>".$rlpcust[0]->las_called_opp."</td>
	         	<td>".$rlpcust[0]->las_pitch."</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->las_lg."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Loan Against Property</td>
	         	<td>".$rlpcust[0]->lap_opp."</td>
	         	<td>".$rlpcust[0]->lap_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td>".$rlpcust[0]->lap_lg."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>HSL</td>
	         	<td>".$rlpcust[0]->hsl_opp."</td>
	         	<td>".$rlpcust[0]->hsl_called_opp."</td>
	         	<td>".$rlpcust[0]->hsl_pitch."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Credit Card</td>
	         	<td>".$rlpcust[0]->cc_eli_new_opp."</td>
	         	<td>".$rlpcust[0]->cc_called_opp."</td>
	         	<td>".$rlpcust[0]->cc_pitch."</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->cc_lg."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>CC Activation</td>
	         	<td>".$rlpcust[0]->cc_activation_opp."</td>
	         	<td>".$rlpcust[0]->cc_activation_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>LI</td>
	         	<td>".$rlpcust[0]->li_opp."</td>
	         	<td>".$rlpcust[0]->li_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>FD</td>
	         	<td>".$rlpcust[0]->fd_opp."</td>
	         	<td>".$rlpcust[0]->fd_called_opp."</td>
	         	<td>".$rlpcust[0]->fd_pitch."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>SAVINGS LTD(Transections  (0-3))</td>
	         	<td>".$rlpcust[0]->ltd_act_saving_opp."</td>
	         	<td>".$rlpcust[0]->ltd_act_saving_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Mobile Banking/Netbanking</td>
	         	<td>".$rlpcust[0]->mb_opp."</td>
	         	<td>".$rlpcust[0]->mb_called_opp."</td>
	         	<td>".$rlpcust[0]->mb_pitch."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td>".$rlpcust[0]->nb_mb_lg."</td>
	         </tr>
	         <tr>
	         	<td>Aadhaar</td>
	         	<td>".$rlpcust[0]->aadhaar_opp."</td>
	         	<td>".$rlpcust[0]->aadhaar_called_opp."</td>
	         	<td>".$rlpcust[0]->aadhaar_pitch."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td>".$rlpcust[0]->aadhaar_activation."</td>
	         </tr>
	         <tr>
	         	<td>Digital 2.0 Score (Inactive)</td>
	         	<td>".$rlpcust[0]->digi2_score_opp."</td>
	         	<td>".$rlpcust[0]->digi2_score_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Digital 2.0 Score (Bill Pay Inactive)</td>
	         	<td>".$rlpcust[0]->digi_billpay_opp."</td>
	         	<td>".$rlpcust[0]->digi_billpay_called_opp."</td>
	         	<td>".$rlpcust[0]->bill_pay_pitch."</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->las_lg."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Digital 2.0 Score(Basic Banking Inactive)</td>
	         	<td>".$rlpcust[0]->digi_basic_banking_opp."</td>
	         	<td>".$rlpcust[0]->digi_basic_banking_called_opp."</td>
	         	<td>".$rlpcust[0]->las_pitch."</td>
	         	<td></td>
	         	<td>".$rlpcust[0]->las_lg."</td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Digital 2.0 Score(Ecom Shopping Inactive)</td>
	         	<td>".$rlpcust[0]->digi_ecom_shopping_opp."</td>
	         	<td>".$rlpcust[0]->digi_ecom_shopping_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Digital 2.0 Score(Investment Inactive)</td>
	         	<td>".$rlpcust[0]->digi_investment_opp."</td>
	         	<td>".$rlpcust[0]->digi_investment_called_opp."</td>
	         	<td>".$rlpcust[0]->invest_pitch."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	         <tr>
	         	<td>Digital 2.0 Score(PHYSICAL Inactive)</td>
	         	<td>".$rlpcust[0]->digi_physical_opp."</td>
	         	<td>".$rlpcust[0]->digi_physical_called_opp."</td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         	<td></td>
	         </tr>
	       </table></div></fieldset>";

	        return $data;

}

function colorCodeRec($id)
{
	$fdirty=$this->recruitdata["dirty"];
	$dataarr=$this->recruitdata["peopledata"];
	$gthis=$this->gthis;
	$edituser=$this->edituser;

	if($edituser)
	{
		$colorarr=array();
		$tarr=explode(",",$gthis->HRCoreVars['colorcodes']);
		foreach($tarr as $tcolor)
		{
			$ttarr=explode(":",$tcolor);
			$colorarr[$ttarr[0]]=$ttarr[1];
		}
		if(isset($colorarr[$dataarr[$id]]))$color=$colorarr[$dataarr[$id]];
		$data="<div style='display:block;height:10px;width:100%;background:$color;'></div>";
	}
	return $data;
}

function CreateForm(&$frm)
{
	$fdirty=$this->recruitdata["dirty"];
	$dataarr=$this->recruitdata["peopledata"];
	$gthis=$this->gthis;
	$edituser=$this->edituser;
	$recruitdata=$this->recruitdata;
	$isuser=$this->isuser;
	$oldbkrec=$this->oldbkrec;
	$themehome=$this->themehome;

	$data="";$i=1;$tabsdata='';$firsttab="active";

	if(Auth::check())
	{
		if(Auth::user()->moduleACL("HR",true,false,false))
		{
			$frm['Files/Logs']["{{id}} {{firstname}}"][]=array();
		}
		if(Auth::user()->moduleACL("Task",true,false,false))
		{
			$frm['Tasks']["{{id}} {{firstname}}"][]=array();
		}
		if(Auth::user()->moduleACL("Dialer",true,false,false))
		{
			$frm['Feedback']["{{id}} {{firstname}}"][]=array();
			$frm['CallHistory']["{{id}} {{firstname}}"][]=array();

				/*if(Auth::user()->username =="B654321" || Auth::user()->username =="B12345"){
				$frm['QuestionAire']["{{id}} {{firstname}}"][]=array();
				$frm['QuestionAireHist']["{{id}} {{firstname}}"][]=array();}*/

				//$frm['QuestionnAire']["{{id}} {{firstname}}"][]=array();
				$frm['CLP']["{{id}} {{firstname}}"][]=array();
				$frm['CLP History']["{{id}} {{firstname}}"][]=array();
				$frm['ComplaintManagement']["{{id}} {{firstname}}"][]=array();
				//$frm['ChildCase']["{{id}} {{firstname}}"][]=array();
				$frm['Racing Format']["{{id}} {{firstname}}"][]=array();
				//if(Auth::user()->username =="B654321" || Auth::user()->username =="B12345")
				//{
				$frm['Lead Entry Form']["{{id}} {{firstname}}"][]=array();
				$frm['RLP']["{{id}} {{firstname}}"][]=array();
				//}
			}
		}

		$tabstr='<div class="tab_bar_green tabsbar-2"><ul class="row row-merge">';
		foreach($frm as $tbname=>$tabs)
		{
			if(($tbname=='Files/Logs'||$tbname=='Letters'||$tbname=='Tasks'||$tbname=='Feedback'||$tbname=='CallHistory')&&!$isuser)continue;

			if($tbname!='')
			{
				$tabstr.="<li class='$firsttab'><a href='#tabs-$i' data-toggle=tab>$tbname</a></li>";
				$tabsdata.="<div class='$firsttab tab-pane ' id=tabs-$i>";
				$firsttab='';

				$fsetstr="";
				foreach($tabs as $fsetname=>$fset)
				{
					$fsetstr.="<div class=tab_generic><fieldset id='fsetid_".$fset[0][5]."'><legend class='new-recruit_legend' style='background:#9CBFFF'><b style='color:white'>".$this->HRTemplateString($fsetname,$this->HRFiledsStr)."</b></legend><div class='box_nrecrut'>";
					$rowval='';
					foreach($fset as $flines)
					{
						if($rowval==''){$rowval=$flines[1][1];if($flines[1][0]==0)$flines[1][0]=1;$fsetstr.="<div style='float:left;width:".(100/$flines[1][0])."%'>";}
						else if($rowval!=$flines[1][1]){$rowval=$flines[1][1];$fsetstr.="</div><div style='float:left;width:".(100/$flines[1][0])."%'>";}

						if($flines[0]!=''&&substr($flines[0], -2)=='~1')
						{
							$fsetstr.="<div class=tab_generic><fieldset style='margin-right:3px;' id='fsetid_".$flines[5]."_1'><legend class='new-recruit_legend' style='background:#9CBFFF'><b style='color:white'>".substr($flines[0], 0, -2)."</b><span class='pull-right'><a href=# onclick='$(\"#fsetid_".$flines[5]."_1_div\").toggle();return false;'><i class='fa fa-sort'></i></a></span></legend><div id='fsetid_".$flines[5]."_1_div'>";
						}
						else if($flines[0]!=''&&substr($flines[0], -2)=='~2')
						{
							$fsetstr.="<div class=tab_generic><fieldset style='margin-right:3px;' id='fsetid_".$flines[5]."_1'><legend class='new-recruit_legend' style='background:#9CBFFF'><b style='color:white'>".substr($flines[0], 0, -2)."</b><span class='pull-right'><a href=# onclick='$(\"#fsetid_".$flines[5]."_1_div\").toggle();return false;'><i class='fa fa-sort'></i></a></span></legend><div id='fsetid_".$flines[5]."_1_div' style='display:none'>";
						}

						if(!($flines[4][2]=='0'&&!$isuser))
						{
							if(!($flines[4][1]=='0'&&!$edituser))
							{
								if($flines[3]=='thumbnail')$fsetstr.=$this->makeThumbImg($flines[5]);
								if($flines[6]=="S")$fsetstr.=$this->makeSelect($flines[5]);
								if($flines[6]=="F")$fsetstr.=$this->makeTextBox($flines[5],"","file");
								if($flines[6]=="T"){$tsz='form_new form_new_amend';if($flines[8]!='')$tsz=$flines[8];$fsetstr.=$this->makeTextBox($flines[5],$tsz);}
								if($flines[6]=="D")$fsetstr.=$this->makeTextBox($flines[5],"");
								if($flines[6]=="A")$fsetstr.=$this->makeTextArea($flines[5]);
								if($flines[6]=="L")$fsetstr.=$this->makeLabelText($flines[5],"");
								if($flines[6]=="M")$fsetstr.=$this->makeMultiSelect($flines[5],$flines[2]);
								if($flines[2]!='')$fsetstr.="<p><lable></lable><font color=#db4453>$flines[2]</font></p>";
							}
						}
						if($flines[0]!=''&&substr($flines[0], -2)=='~0')
						{
							$fsetstr.="</div></fieldset></div>";
						}
					}
					$fsetstr.="</div></div></fieldset></div>";if($rowval=='')$fsetstr='';
				}
				$tabsdata.=$fsetstr;
				if($tbname=='Files/Logs'&&$isuser)$tabsdata.=$this->createFilesTab();
				if($tbname=='Tasks'&&$edituser)$tabsdata.=$this->createTasksTab();
				if($tbname=='Feedback')$tabsdata.=$this->createDispoTab();
				if($tbname=='CallHistory')$tabsdata.=$this->createCallsTab();
				if($tbname=='CLP')$tabsdata.=$this->createQaireTab();
				if($tbname=='CLP History')$tabsdata.=$this->createQaireHistTab();
				if($tbname=='ComplaintManagement')$tabsdata.=$this->createCompManage();
				if($tbname=='ChildCase')$tabsdata.=$this->createChildCase();
				//if($tbname=='RacingCustomer')$tabsdata.=$this->createRacingCust();
				if($tbname=='Racing Format')$tabsdata.=$this->createRacingCust();
				if($tbname=='Lead Entry Form')$tabsdata.=$this->createLeadEntryForm();
				if($tbname=='RLP')$tabsdata.=$this->createRLP();
				$tabsdata.="</div>";
				$i++;
			}
		}
		$tabstr.='</ul></div>';

		$data="<div class=relativeWrap>".$tabstr.'<div class="tab-content">'.$tabsdata.'</div>'."</div>";


		$data="<div id=createtaskdiv></div><div style='clear:both'></div>".$this->colorCodeRec('candidatecategory').$data.$this->CreateFormScripts();
		return $data;
	}
	
	function CreateFormScripts()
	{
		$varid=$this->varid;

		$wakka=$this->gthis;
		$hrexclusiveflag=0;if(empty($this->recruitdata["peopledata"]['client']))$this->recruitdata["peopledata"]['client']='__';
		if(strstr($this->HRExclusiveClients,$this->recruitdata["peopledata"]['client']))
		{
			if(!$wakka->IsAdmin())
			{
				if(!strstr($wakka->getManagerUsers($wakka->getUserListforClient($this->recruitdata["peopledata"]['client'])),$wakka->GetUserName()))
				{
					if(!strstr($wakka->GetBBBUserData("clientsownerlist"),$this->recruitdata["peopledata"]['client']))$hrexclusiveflag=1;
				}
			}
		}
		if(!$this->isuser)$hrexclusiveflag=0;

		$recordDetails = DB::table('records')->where('id','=',$varid)->select('mf_isa','emailid')->get();
		$priority = $recordDetails[0]->mf_isa;
		$emailid = $recordDetails[0]->emailid;

		$data=" <div id=recdialog></div><br><input type=hidden name='id' id='id' value='".$this->varid."'>
		<input type=hidden name='workflowstatus' id='workflowstatus' value='".$this->recruitdata["peopledata"]["workflowstatus"]."'>
		<input type=hidden name=varid id=varid value='".$this->varid."'>
		<input type=hidden name=status id=status value='".$this->recruitdata["peopledata"]["status"]."'>
		<script>$(document).ready(function() {try{".$this->emprecordScripts."}catch(e){}});
			\$(document).ready(function()
			{
				var dialerFlagExit=0;
				if(\$('#dialer_flag').length)
				{
					if('".$this->recruitdata["peopledata"]['dialer_flag']."'=='VIP')
					{
						\$('#dialer_flag').val('".$this->recruitdata["peopledata"]['dialer_flag']."');

						dialerFlagExit=1;
					}

					if('".$priority."'=='VIP' && dialerFlagExit!=1)
					{
						\$('#dialer_flag').val('".$priority."');
					}
				}
                if('".$priority."'=='VIP' && dialerFlagExit!=1)
					{
						\$('#dialer_flag').val('".$priority."');
					}
				if (typeof kSetDData === 'function')kSetDData('C','crmid',".$this->varid.");
			});
		</script>";
       $data.="<a href='product.php?userid=".base64_encode(Auth::user()->id)."&cust_name=".base64_encode($this->recruitdata["peopledata"]['firstname'])."
				&cust_id=".base64_encode($this->recruitdata["peopledata"]['clientcode'])."&mobile_number=".base64_encode($this->recruitdata["peopledata"]['mobile'])."&emailid=".base64_encode($emailid)."'target='_blank'><input type=button class='btn btn-green' value='DAP DATA' ></a>";
            
            if($this->isuser&&$this->edituser)//&&$this->recruitdata["peopledata"]['currentstatus']!=$wakka->HRCoreVars["systemExitStatus"]
            {
            	$data.="<input type=button class='btn btn-green' value='Save Data' id=recruitsavedata onclick='recruitData();return false;'>
            	<input title='' class='tooltip tooltip1 btn btn-green_outline' type=button value='Reload Data' onclick='showRecruit(\"".$this->varid."\");return false;'>
            	";
            	if(Auth::check()&&Auth::user()->moduleACL("Task",true,false,false))$data.="<input title='' class='tooltip tooltip1 btn btn-green_outline' type=button value='User Task' onclick='createTask(\"".$this->varid."\");return false;'>";
            	$data.="
            	<script>
            		function recruitData()
            		{
            			var postdata='varid='+$('#varid').val();

            			var varslist='".$this->HRFiledsStr."';
            			var varsarr=varslist.split(',');
            			for(var i=0;i<varsarr.length;i++)
            			{
            				if(varsarr[i]!=''&&$('#'+varsarr[i]).length)postdata+='&'+varsarr[i]+'='+encodeURIComponent($('#'+varsarr[i]).val());
            			}

            			doAjax('record?action=save',postdata,'createtaskdiv','ajaxMutex_recSaveData','singlethis','POST');
            		}
            	</script>";
            }
            if($this->oldbkrec)
            {
            	$data.="<input title='' class='tooltip tooltip1 btn btn-green_outline' type=button value='HR Closure' onclick='bkempclosure(\"".$this->bkvarid."\",\"hr\");return false;'>
            	<input title='' class='tooltip tooltip1 btn btn-green_outline' type=button value='Accounts Closure' onclick='bkempclosure(\"".$this->bkvarid."\",\"account\");return false;'>
            	<script>
            		function bkempclosure(tid,tmodule)
            		{
            			if(confirm('This Will mark Current Record Closed by your ID. Proceed?'))
            			{
            				var postdata='tid='+tid+'&tmodule='+tmodule;
            				doAjax('hr?action=BKEmpClosure',postdata,'searchresults');
            			}
            		}
            	</script>";
            }
            
            if($this->isuser&&$this->edituser)
            {
            	$data.="<script>
            	var filevarstrlistarr='".$this->HRFileFieldsStr."'.split(',');
            	for(var i=0;i<filevarstrlistarr.length;i++)if(filevarstrlistarr[i]!=''&&$('#'+filevarstrlistarr[i]).length)ajaxFileUpload(filevarstrlistarr[i],'".$this->varid."');
            		var datevarstrlistarr='".$this->HRDateFilds."'.split(',');
            	for(var i=0;i<datevarstrlistarr.length;i++)if(datevarstrlistarr[i]!=''&&$('#'+datevarstrlistarr[i]).length)$('#'+datevarstrlistarr[i]).datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '".(date('Y')-70).":".(date('Y')+20)."'});
            		ajaxFileUpload('genericfileselect','".$this->varid."');
            	function saltotal()
            	{
            		var stotal=0;

            		if($('#salbasic').val()=='')$('#salbasic').val('0');
            		if($('#salhouserent').val()=='')$('#salhouserent').val('0');
            		if($('#saltransport').val()=='')$('#saltransport').val('0');
            		if($('#salfood').val()=='')$('#salfood').val('0');
            		if($('#saltelephone').val()=='')$('#saltelephone').val('0');
            		if($('#salmedical').val()=='')$('#salmedical').val('0');
            		if($('#salelectricity').val()=='')$('#salelectricity').val('0');
            		if($('#salother').val()=='')$('#salother').val('0');

            		stotal+=parseFloat($('#salbasic').val());
            		stotal+=parseFloat($('#salhouserent').val());
            		stotal+=parseFloat($('#saltransport').val());
            		stotal+=parseFloat($('#salfood').val());
            		stotal+=parseFloat($('#saltelephone').val());
            		stotal+=parseFloat($('#salmedical').val());
            		stotal+=parseFloat($('#salelectricity').val());
            		stotal+=parseFloat($('#salother').val());

            		$('#saltotal').val(stotal);
            	}
            	$('#salelectricity').keyup(saltotal);
            	$('#salmedical').keyup(saltotal);
            	$('#saltelephone').keyup(saltotal);
            	$('#saltransport').keyup(saltotal);
            	$('#salhouserent').keyup(saltotal);
            	$('#salbasic').keyup(saltotal);
            	$('#salfood').keyup(saltotal);
            	$('#salother').keyup(saltotal);
            	$('#saltotal').keyup(saltotal);

            	function recd_sendmail(filepath){mailFile(filepath,$('#recd_to').val(),$('#recd_subject').val(),$('#recd_from').val(),encodeURIComponent($('#recd_message').val()));}
            	function mailFileDialog(filepath)
            	{
            		var dhtml='<fieldset><legend class=\"new-recruit_legend\">Send File as Email</legend>';
            		dhtml+='<p style=\"clear:both\"><label class=label-small_new  style=\"width:25%\">From:</label><select class=\"form_hrm_select\" style=\"width:50%\" id=recd_from><option value=system>System</option><option value=\"".$wakka->GetUserName()."\">".$wakka->GetUserName()."</option></select></p>';
            		dhtml+='<p style=\"clear:both\"><label class=label-small_new  style=\"width:25%\">To (comma sep):</label><input type=text id=recd_to class=\"form_new form_new_amend\" value=\"".$this->recruitdata["peopledata"]["emailid"]."\"></p>';
            		dhtml+='<p style=\"clear:both\"><label class=label-small_new  style=\"width:25%\">Subject:</label><input type=text id=recd_subject class=\"form_new form_new_amend\" value=\"".$this->varid." Innovation : File Attached\"></p>';
            		dhtml+='<p style=\"clear:both\"><label class=label-small_new  style=\"width:25%\">Message:</label><textarea class=\"form_new form_new_amend\" id=recd_message style=\"width:60%\">Please find the Document Attached</textarea></p>';
            		dhtml+='<p style=\"clear:both\"><label class=label-small_new  style=\"width:25%\">Attachment:</label>'+filepath+'</p>';
            		dhtml+='</fieldset>';

            		$('#recdialog').html('');
            		$('#recdialog').html(dhtml);

            		$('#recdialog').dialog({
            			autoOpen: false,
            			width: '70%',
            			buttons: {
            				'Send Mail' : function() {
            					recd_sendmail(filepath);$(document).scrollTop(0);
            					$(this).dialog('close');
            				},
            				'Close': function() {
            					$(this).dialog('close');
            				}
            			}
            		});
            		$('#recdialog').dialog('open');
            	}

            	function deleteTask(tid)
            	{
            		var postdata='tid='+tid;
            		doAjax('hr?action=DeleteTask',postdata,'createtaskdiv');
            	}
            	function ajaxFileUpload3(eid,varid)
            	{
            		var flg=1;
            		var gn='';
            		var uhandle=$('#'+eid).ajaxfileupload({
            			'action': 'hr?action=PdfSplit',
            			'params': {
            				'name': eid,
            				'varid' : varid,
            				'gr':gn,
            			},
            			'onComplete': function(response) {
            				if(response.status==false)
            				{
            					$('#createtaskdiv').html('<div class=\"message error close\"><h2>Error!</h2><p>'+response.message+'</p></div>');
            					messageCloseFun();
            					$('#'+eid).val('');
            					return false;
            				}
            				else
            				{
            					$('#createtaskdiv').html('<div class=\"message success close\"><h2>Success!</h2><p>File Uploaded</p></div>');
            					messageCloseFun();
            				}
            			},
            			'onStart': function() {
            				flg=1;
            				$('#fd'+eid).html('<font color=#4b89dc>Uploading...</font>');
            				console.log('started:');
            			},
            			'onCancel': function() {
            				console.log('no file selected');
            			}
            		});

            		return false;
            	}
            	ajaxFileUpload3('pdfsplitfile',".$this->varid.");
            	function clearFileVars()
            	{
            		for(var i=0;i<filevarstrlistarr.length;i++)if(filevarstrlistarr[i]!=''&&$('#'+filevarstrlistarr[i]).length)$('#'+filevarstrlistarr[i]).val('');
            	}
            function approveFData(tid,tvarid)
            {
            	var postdata='tid='+tid+'&varid='+tvarid;
            	doAjax('hr?action=RecruitApprove',postdata,'createtaskdiv');
            	return false;
            }
            function renewRecord()
            {
            	if(confirm('This Will Archive Current Client data and clean the record. Are you sure?'))
            	{
            		var postdata='varid='+$('#varid').val();
            		doAjax('hr?action=RenewRecord',postdata,'createtaskdiv');
            	}
            }
            function blacklistcandidate()
            {
            	if(confirm('This Will mark candidate as Blacklisted. Are you sure?'))
            	{
            		var postdata='varid='+$('#varid').val();
            		doAjax('hr?action=BlacklistRecord',postdata,'createtaskdiv');
            	}
            }
        </script>";
    }
    if($hrexclusiveflag==1)
    {
    	$data.="<script>
    	$(document).ready(function(){
    		$('#tabs-6').css({'display':'none'});
    		$('#tabs-7').css({'display':'none'});
    		$('#tabs-9').css({'display':'none'});
    		$('#tabs-10').css({'display':'none'});
    		$('#tabs-11').css({'display':'none'});
    	});
    </script>";
}

return $data;
}


function checkDuplicate($varid,$key,$val)
{
	$gthis=$this->gthis;
	if($val=="")
	{
		return false;
	}
	else
	{
		$cachearray=explode(",",$gthis->EMPCacheCols);
		if(in_array($key,$cachearray)&&$key!='')
		{
			if($gthis->getCount("records","`$key`='$val' and id!='$varid'"))
				return true;
			else
				return false;
		}
		else
		{
			if($gthis->getCount("records","peopledata like '%\"$key\";s:".strlen($val).":\"$val\"%' and id!='$varid'"))
			return true;
			else
				return false;
		}
	}
}

function chechAlNum($val)
{
	if($val=="")
	{
		return true;
	}
	else
	{
		if(ctype_alnum($val))
			return true;
		else 
			return false;
	}
}
function validatePostData()
{
	$varid=$this->varid;
	$wakka=$this->gthis;
	$ppldata=$this->recruitdata["peopledata"];
	$message='';
	if($wakka->getCount("records","id='$varid'")!=1)$message=" Record doesnot exists, ";

		//only if active statuses
	$empstatus=Input::get('currentstatus');if($empstatus=="")$empstatus="__NOCHECK__";

	if(stristr($wakka->HRCoreVars['hrrecruitstatuses'],$empstatus)||stristr($wakka->HRCoreVars['hrworkingstatus'],$empstatus))
	{
			//$this->HRForms[$parts[3]][$parts[4]][]=array($parts[5],$parts[6],$parts[7],$parts[8],$parts[9],$parts[0],$parts[1],$parts[2],$parts[10]);
		foreach($this->HRForms as $tbname=>$tabs)
		{
			if($tbname!='')
			{
				foreach($tabs as $fsetname=>$fset)
				{
					foreach($fset as $flines)
					{
						if($flines[3]!="")
						{
							$validations=explode("|",$flines[3]);
							foreach($validations as $vline)
							{
								if($vline!="")
								{

									$vline=str_replace("__COMMA__",",",$vline);
									$fline5=Input::get($flines[5]);

										//$message.="[$flines[5]|$vline] ";
									if($vline=="NONEMPTY")
									{
										if(empty($fline5))$message.=" ".$this->HRFieldNames[$flines[5]].",";
									}
									else if(substr($vline,0,5)=="REGEX"&&$fline5!='')
									{
										if(!preg_match("/".substr($vline,5)."/", $fline5))$message.=" Invalid ".$this->HRFieldNames[$flines[5]].",";
									}
									else if($vline=="NODUP")
									{
										if($this->checkDuplicate($varid,$flines[5],Input::get($flines[5])))$message.=" ".$this->HRFieldNames[$flines[5]]." Already Exists".",";
									}
									else if($vline=="ALNUM")
									{
										if(!$this->chechAlNum(Input::get($flines[5])))$message.=" ".$this->HRFieldNames[$flines[5]]." Can only Have Numbers and Letters".",";
									}
									else if(substr($vline,0,8)=="DT_C_MEX"&&$ppldata[$flines[5]]==''&&Input::get($flines[5])!='')
									{
										$duration = explode(".",Input::get($flines[5]));
										if(sizeof($duration)==3)
										{
											$duration=mktime(0, 0, 0, $duration[1], $duration[0], $duration[2]);
											if($duration-time()-(intval(substr($vline,8))*30*24*60*60)<=0)$message.=" ".$this->HRFieldNames[$flines[5]]." needs to more then ".substr($vline,8)." months,";
										}
										else $message.=" Error : ".$this->HRFieldNames[$flines[5]];
									}
									else if(substr($vline,0,8)=="DT_D_MEX"&&Input::get($flines[5])!='')
									{
										$duration = explode(".",Input::get($flines[5]));
										if(sizeof($duration)==3)
										{
											$duration=mktime(0, 0, 0, $duration[1], $duration[0], $duration[2]);
											if(time()-$duration-(intval(substr($vline,8))*30*24*60*60)<=0)$message.=" ".$this->HRFieldNames[$flines[5]]." needs to more then ".substr($vline,8)." months,";
										}
										else $message.=" Error : ".$this->HRFieldNames[$flines[5]];
									}
								}
							}
						}
					}
				}
			}
		}

			//select values check
		$dropsarr=explode(",",$this->HRDropFilds);
		foreach($dropsarr as $dropitem)
		{
			if($dropitem=='client')$selvals=implode("~",$this->gthis->clientsReadAccess());
			else $selvals=$this->FormSelectVals[$dropitem];
			
			if(Input::get($dropitem)!=''&&Input::get($dropitem)!='undefined'&&!strstr($selvals,trim(Input::get($dropitem))))
				$message.=" Wrong Value of '".$this->HRFieldNames[$dropitem]."'";
		}

			//date check
		$datesarr=explode(",",$this->HRDateFilds);
		foreach($datesarr as $dateitem)
		{
			$dateitem=trim($dateitem);
			if($dateitem!='')
			{
				if(Input::get($dateitem)!=''&&Input::get($dateitem)!='undefined')
				{
					$dtparts=explode(".",Input::get($dateitem));
					if(sizeof($dtparts)==3&&intval($dtparts[0])<32&&intval($dtparts[1])<13&&intval($dtparts[2])>1900);
					else $message.=" Wrong Value of '".$this->HRFieldNames[$dateitem]."'";
				}
			}
		}
	}

		//client cannot be changed unless Admin
	if(!$wakka->IsAdmin())if(trim($ppldata["client"])!=""&&$ppldata["client"]!=Input::get("client"))$message=" Client Cannot be changed, use Renew-Record";

	if(Input::get('currentstatus')==$wakka->HRCoreVars['hrTriggerHoldStatus'])
	{
			$message="";//bypass checks for candidates
		}
		return $message;
	}
	
	function updateArrayWithPostData()
	{
		$ppldata=$this->recruitdata["peopledata"];
		$changearr=$this->recruitdata['modifylog'];
		$wakka=$this->gthis;
		
		$ppldata['varid']=Input::get('varid');
		$ppldata['id']=Input::get('varid');
		$client=Input::get('client');

		//file vars change the file names to store,and if empty keep the old name
		$tmpstr=explode(",",$this->HRFileFieldsStr);
		foreach($tmpstr as $tmpelem)
		{
			$elemfname=$ppldata['varid']."_".$tmpelem.".pdf";
			if(Input::has($tmpelem))
			{
				$ppldata[$tmpelem]=$wakka->safeString(Input::get($tmpelem));//save the new name as old val in case of files
				Input::merge(array($tmpelem => $elemfname));
				$this->recruitdata['dirty'][$tmpelem]=1;
			}
			else if(!empty($ppldata[$tmpelem]))
			{
				if($ppldata[$tmpelem]==$elemfname||$ppldata[$tmpelem]=="")
				{
					Input::merge(array($tmpelem => $ppldata[$tmpelem]));
				}
				else 
				{
					Input::merge(array($tmpelem => $elemfname));
				}
			}
		}

		$tmpstr=explode(",",$this->HRFiledsStr);
		$newdata=array();foreach($tmpstr as $key)
		{
			if(Input::exists($key))$newdata[$key]=trim(Input::get($key));
		}
		
		foreach($newdata as $key=>$newval)
		{
			$val=$ppldata[$key];
			if($newval!=trim($val))
			{
				if(strstr($changearr[$changearr["updated"]],$key)==FALSE)$changearr[$changearr["updated"]].="$key|".str_replace(array("|",",")," ",$val)."|".str_replace(array("|",",")," ",$wakka->safeString($newval)).",";
				$this->recruitdata['dirty'][$key]=1;

				$this->empWorkflowTrigger($ppldata['varid'],$client,$key,$newval,$val,$ppldata,$newdata);
				$this->empAnalytics($ppldata['varid'],$ppldata,$key,$newval,$val);
			}
		}

		foreach($tmpstr as $tmpelem)
		{
			if(Input::exists($tmpelem))
			{
				$ppldata[$tmpelem]= $wakka->safeString(Input::get($tmpelem));
				if($ppldata[$tmpelem]=="")unset($ppldata[$tmpelem]);
			}
		}


		//run holded up triggers if
		if($newdata["currentstatus"]!=$wakka->HRCoreVars['hrTriggerHoldStatus'])
		{
			$triggers=$wakka->LoadAll("select * from hrms_triggerhold where varid='".$ppldata['varid']."'");
			foreach($triggers as $trigger)
			{
				if($trigger['varid']==$ppldata['varid'])
				{
					$triggerdata=unserialize($trigger['data']);
					$triggerdata['newdata']["currentstatus"]=$newdata["currentstatus"];
					$this->empWorkflowTrigger($triggerdata['varid'],$triggerdata['client'],$triggerdata['key'],$triggerdata['newval'],$triggerdata['oldval'],$triggerdata['postvars'],$triggerdata['newdata']);
				}
			}
			$wakka->Query("delete from hrms_triggerhold where varid='".$ppldata['varid']."'");
		}
		
		$this->recruitdata["peopledata"]=$ppldata;
		$this->recruitdata['modifylog']=$changearr;
	}
	
	function processFormSubmit()
	{
		if(Auth::guest())return "Error-401";

		$wakka=$this->gthis;
		$tasknotification='';
		$resultstr="";
		$result=false;
		$varid=$this->varid;

		$message=$this->validatePostData();
		if($message==""||$wakka->IsAdmin())
		{
			if($message!="")$tasknotification.="Please Check: $message<br>";

			$this->updateArrayWithPostData();

			//$res=$wakka->setPerson($varid,$this->recruitdata);
			if($res<0)
			{
				$resultstr="<div class='alert alert-danger'><strong>Record Add/Update Error!</strong><p>Serialization Error.. Cannot Save</p></div><script>simpleNotification('error','topRight','Error. Cannot Save');</script>";
			}
			else
			{
				$result=true;

				$wakka->cleanSystemTaskbyID($varid,$this->HRFiledsStr);
				$tasksemp=$wakka->LoadAll("select name from hrms_tasks where empid='$varid' and status in ('NEW','WIP')");
				foreach($tasksemp as $tline)$tasknotification.=$tline['name']."<br>";

				if($tasknotification==''){$resultstr="<div class='alert alert-success'><strong>Record Updated!</strong><p>Record Data Updated Successfully, you may search and edit or continue to edit data.</p><div style='display:none' id='happy'><img src='/assets/images/emot/happy.jpg' height='80' width='80'></div><div style='display:none' id='sad'><img src='/assets/images/emot/sad.png' height='80' width='80'></div></div><script>clearFileVars();</script><script>simpleNotification('success','topRight','Saved Successfully');

			</script>";}
			else {$resultstr="<div class='alert alert-success'><strong>Data Saved with Task Escalation</strong><p>Tasks Created:- <br>$tasknotification</p></div><script>clearFileVars();</script><script>simpleNotification('success','topRight','Saved Successfully');</script>";
		}				

		$resultstr.= $this->getProcess($this->recruitdata['peopledata'],$wakka);


				//sanity check files and task
		$recruitdata=$this->recruitdata;
		$tmpstr=explode(",",$this->HRFileFieldsStr);
		$fixedcnt=0;
		foreach($tmpstr as $tmpelem)
		{
			if(file_exists($this->storagehome."/recruits/$varid/$varid"."_".$tmpelem.".pdf"))
			{
				if($recruitdata["peopledata"][$tmpelem]!="$varid"."_".$tmpelem.".pdf"){$recruitdata["peopledata"][$tmpelem]="$varid"."_".$tmpelem.".pdf";$fixedcnt++;}
			}
			else
			{
				if(isset($recruitdata["peopledata"][$tmpelem])&&$recruitdata["peopledata"][$tmpelem]!=""){$recruitdata["peopledata"][$tmpelem]="";$fixedcnt++;}
			}
		}
				//set fdirty with WIP fields
		$recruitdata["dirty"]=array();
		$taskslist=$wakka->LoadAll("select * from hrms_tasks where empid='$varid' and status in ('NEW','WIP') and creatorid='System' and completecheck!=''");
		foreach($taskslist as $taskline)
		{
			$recruitdata["dirty"][$taskline['completecheck']]=1;
		}
		$this->recruitdata=$recruitdata;
		$res=$wakka->setPerson($varid,$this->recruitdata);

	}
}
else
{
	$resultstr="<div class='alert alert-danger'><strong>Record Add/Update Error!</strong><p>Please Check : $message</p></div><script>simpleNotification('error','topRight','Error in saving, Check Errors');</script>";
}

return $resultstr;
}


function buildUL($tooltip,$fpath,$text,$tdata="",$onclick="")
{
	$data="<ul class='dash dash2' onclick='$onclick return false;'>
	<li>
		<a href=# onclick='return false;' title='$tooltip' class=tooltip>
			<img src='$fpath' alt='' tdata='$tdata' />
			<span>$text</span>
		</a>
	</li>
</ul>";
return $data;
}
function getProcess(&$ppldata,&$gthis)
{

}

function getStageStatus(&$gthis,$stagestr,&$ppldata,$imgoverride="")
{
	$completed=true;$tdata="";$titleD=array();
	$wfstrs=explode("_",$stagestr);
	$tfields=explode(",",$gthis->HRCoreVars[$stagestr]);
	foreach($tfields as $tfield)
	{
		if($tfield!="")
		{
			if(!isset($ppldata[$tfield]))$ppldata[$tfield]='';
			
			if($ppldata[$tfield]==""){$completed=false;$title[]="Missing : ".$tfield;}
			else {$titleD[]="Done : ".$tfield." = ".$ppldata[$tfield];}
		}
	}
	$title[]="<br>";if(is_array($titleD))$title=array_merge($title,$titleD);

	if($completed)$imgoverride="tick_48";
	if(!$completed&&$imgoverride=="")$imgoverride="stop_48";

	if($imgoverride!="stop_48"&&$tdata!="stop_48,err1")
	{
			//if last stage is done set system exit status
		if($stagestr=="WF_Exit"||$stagestr=="WF_UUVC")
		{
			$gthis->setPersonKey($ppldata["id"],"generalremarks","[[System:- Exiting Candidate, Removing from Workflow (".date("d.M.Y").").]] ".$ppldata["generalremarks"],"System");
			$gthis->setPersonKey($ppldata["id"],"currentstatus",$gthis->HRCoreVars["systemExitStatus"],"System");
			$gthis->setPersonKey($ppldata["id"],"workflowstatus","");
			$gthis->setPersonKey($ppldata["id"],"workflowstatusS","");
		}
	}
	else 
	{
		if(isset($wfstrs[1]))
		{
			if($ppldata["workflowstatus"]!=$wfstrs[1])$gthis->setPersonKey($ppldata["id"],"workflowstatus",$wfstrs[1]);
			if($ppldata["workflowstatusS"]!=$imgoverride)$gthis->setPersonKey($ppldata["id"],"workflowstatusS",$imgoverride);
		}

		$wfstrs[1].="_ToDo";
	}

	if(!isset($ppldata['generalremarks']))$ppldata['generalremarks']='';

	if($completed)return $this->buildUL(implode("<br>",$titleD),$this->themehome."/assets/icons/$imgoverride.png",$wfstrs[1],$tdata,"Rpopupopen(\"$ppldata[id]\",\"$stagestr\",\"$ppldata[generalremarks]\");");
	else          return $this->buildUL(implode("<br>",$title), $this->themehome."/assets/icons/$imgoverride.png",$wfstrs[1],$tdata,"Rpopupopen(\"$ppldata[id]\",\"$stagestr\",\"$ppldata[generalremarks]\");");
}


function empWorkflowTrigger($varid,$client,$key,$newval,$oldval,&$postvars,&$newdata)
{

}
function empAnalytics($varid,&$ppldata,$key,$newval,$oldval)
{

}
//Log::info($data);

}