<?php
session_start();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['companymailid'];
$createby=$_SESSION['emailid'];
//if(($adminemailid !="")&&($companyname!="")){
require_once('../Control/address.php');
$objaddress=new addressctrl();
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/contact.php');
$objcontact=new contactctrl();
require_once('../Control/status.php');
$objstatus=new statusctrl();
require_once('../Control/tag.php');
$objtag=new tagctrl();
require_once('../Control/employee.php');
$objemployee=new employeectrl();
require_once('../Control/leadsource.php');
$objleadsource=new leadsourcectrl();
?>
<html>
    
    <head>
        
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        <script src="../../Bootstrap/bootstrapAlert.js"></script>
        <link rel="stylesheet" href="../../font-awesome-4.7.0/css/font-awesome.min.css">
        
        <!-- FormValidation CSS file -->
        <link rel="stylesheet" href="../../Formvalidation/formValidation.min.css">
        <!-- FormValidation plugin and the class supports validating Bootstrap form -->
        <script src="../../Formvalidation/formValidation.min.js"></script>
        <script src="../../Formvalidation/framework.min.js"></script>
        <!-- Edit Select Picker -->
        <script src="../../Editablepicker/jquery-editable-select.min.js"></script>
        <link href="../../Editablepicker/jquery-editable-select.min.css" rel="stylesheet">
        <!-- Select Picker -->
        <script src="../../Selectpicker/bootstrap-select.js"></script>
        <link href="../../Selectpicker/bootstrap-select.min.css" rel="stylesheet">
        <!-- Date Picker -->
       <!-- <link rel="stylesheet" href="../../Datepicker/jquery-ui.css">
        <script src="../../Datepicker/jquery-ui.js"></script>-->
        
        <!--bootstrap datepicker-->
        <link href="../../Datepicker/bootstrap-datepicker.css" rel="stylesheet" type="text/css" />
        <script src="../../Datepicker/bootstrap-datepicker.js"></script>
        
        <!-- SweetAlert -->
        <link rel="stylesheet" href="../../SweetAlert/sweetalert.css">
        <link rel="stylesheet" href="../../SweetAlert/sweetalert.min.css.map">
        <script src="../../SweetAlert/sweetalert.js"></script>
        <!-- clockpicker -->
        <link href="../../Clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet" type="text/css" />
        <link href="../../Clockpicker/github.min.css" rel="stylesheet" type="text/css" />
        <script src="../../Clockpicker/jquery-clockpicker.min.js"></script>
    
        <link href="deal_action_stream.css" rel="stylesheet">
        <script src="deal_action_stream.js"></script>
        
        <style>
            .contacts_caption .caption-top .letters-list {
                float: right;
            }
            .letters-list {
                float: left;
                margin: 0 0 0 50px;
            }
            ol, ul {
                list-style: none;
            }
            .letters-list li {
                display: block;
                text-transform: uppercase;
                color: #999;
                height: 24px;
                float: left;
                margin-left: 3px;
            }
            .letters-list li a.inactive {
                color: #666;
                cursor: default;
            }
            .letters-list li a {
                padding: 0 5px;
                font-size: 14px;
                text-decoration: none;
                display: inline-block;
                text-align: center;
                color: #77c300;
            }
            .top .letters-list li a, .caption-top .letters-list li a {
                padding: 0 1px;
                font-size: 14px;
            }
            a {
                cursor: pointer;
                color: #6699cc;
                outline: medium none;
                text-decoration: none;
                -webkit-user-select: auto;
            }/*
            [type="checkbox"]:not(:checked)+label:before, [type="checkbox"]:checked+label:before {
                content: "";
                background: url(Image/checkboxes.png) -3px -61px no-repeat;
                width: 22px;
                height: 23px;
                position: absolute;
                left: 0px;
                top: -3px;
            }
            [type="checkbox"]:checked+label:after, [type="checkbox"]:indeterminate+label:after {
                content: "";
                background: url(Image/checkboxes.png) -3px -1px no-repeat;
                width: 22px;
                height: 23px;
                position: absolute;
                left: -4px;
                top: -3px;
            }*/
            /*.show_contacts:before {
                background: url(Image/common_icons.png) no-repeat 0 -32px transparent;
                width: 9px;
                height: 13px;
                display: block;
                position: absolute;
                content: "";
                top: 7px;
                left: 77px;
                background-color:#b3de6f;
            }
            .show_companies:before {
                background: url(Image/common_icons.png) no-repeat -9px -32px transparent;
                width: 17px;
                height: 12px;
                display: block;
                position: absolute;
                content: "";
                top: 6px;
                left: 97px;
            }*/
            .contact_org{
                width: 64px;
            }
            .white-grey-btn{
                padding: 2px 10px;
                border-style: solid;
                border-width: 1px;
                border-color: #d5d5d5 #d5d5d5 #dfdfdf;
                background: -moz-linear-gradient(center top, #fff 20%, #f8f8f8 100%);
                background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f8f8f8));
                background: -ms-linear-gradient(top, #fff 20%, #f8f8f8 100%);
                background: -webkit-linear-gradient(top, #fff 20%, #f8f8f8 100%);
                background: -o-linear-gradient(top, #fff 20%, #f8f8f8 100%);
                background: linear-gradient(#fff, #f8f8f8);
                -webkit-border-radius: 3px;
                -moz-border-radius: 3px;
                border-radius: 3px;
                z-index: 2;
            }
            .white-green-btn{
                padding: 2px 10px;
                border-style: solid;
                border-width: 1px;
                border-color: #d5d5d5 #d5d5d5 #dfdfdf;/*
                background: -moz-linear-gradient(center top, #fff 20%, #f8f8f8 100%);
                background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f8f8f8));
                background: -ms-linear-gradient(top, #fff 20%, #f8f8f8 100%);
                background: -webkit-linear-gradient(top, #fff 20%, #f8f8f8 100%);
                background: -o-linear-gradient(top, #fff 20%, #f8f8f8 100%);
                background: linear-gradient(#fff, #f8f8f8);*/
                -webkit-border-radius: 3px;
                -moz-border-radius: 3px;
                border-radius: 3px;
                z-index: 2;
                background-color:#b3de6f;
            }
            .refresh:before {
                background: url(Image/pipelinemenu.png) no-repeat 100% -67px transparent;
                width: 13px;
                height: 13px;
                display: block;
                position: absolute;
                content: "";
                left: 0;
                top: 0;
            }
        </style>
         <style>
        .checkbox label:after, 
        .radio label:after {
            content: '';
            display: table;
            clear: both;
        }
        .dropdown-content a {
            color: black;
            padding: 10px 10px;
            text-decoration: none;
            display: block;
            background-color: white;
        }
        .checkbox .cr,
        .radio .cr {
            position: relative;
            display: inline-block;
            border: 1px solid #a9a9a9;
            border-radius: .25em;
            width: 1.3em;
            height: 1.3em;
            float: left;
            margin-right: .5em;
        }
        
        .radio .cr {
            border-radius: 50%;
        }
        
        .checkbox .cr .cr-icon,
        .radio .cr .cr-icon {
            position: absolute;
            font-size: .8em;
            line-height: 0;
            top: 50%;
            left: 20%;
        }
        
        .radio .cr .cr-icon {
            margin-left: 0.04em;
        }
        
        .checkbox label input[type="checkbox"],
        .radio label input[type="radio"] {
            display: none;
        }
        
        .checkbox label input[type="checkbox"] + .cr > .cr-icon,
        .radio label input[type="radio"] + .cr > .cr-icon {
            transform: scale(3) rotateZ(-20deg);
            opacity: 0;
            transition: all .3s ease-in;
        }
        
        .checkbox label input[type="checkbox"]:checked + .cr > .cr-icon,
        .radio label input[type="radio"]:checked + .cr > .cr-icon {
            transform: scale(1) rotateZ(0deg);
            opacity: 1;
        }
        
        .checkbox label input[type="checkbox"]:disabled + .cr,
        .radio label input[type="radio"]:disabled + .cr {
            opacity: .5;
        }
    </style>
        <script>
            function gotoorg(){
                window.location.replace("contactlist_org.php");
            }
        </script>
        <style>
            .divshowmoreaction {
                width: 360px;
                height: 45px;
                left: 110px;
                top: 0px;
                background-color: #3d3d3d;
                position: fixed;
                z-index:121;
                -webkit-animation-name: example; /* Safari 4.0 - 8.0 */
                -webkit-animation-duration: 4s; /* Safari 4.0 - 8.0 */
                animation-name: example;
                animation-duration: 2s;
                border-radius:5px;
            }
            @-webkit-keyframes example {
                0%   {background-color:#3d3d3d; left:110px; top:-10px;}
            }
        </style>
        <style>
            .dropbtn {
                background-color: #f2f2f2;
                color: black;
                margin-left:6px;
                margin-top:6px;
                padding: 6px;
                font-size: 14px;
                border: none;
                cursor: pointer;
                border-radius:2px
            }
            
            .dropbtn:hover, .dropbtn:focus {
                background-color: white;
            }
            
            .dropdown {
                position: relative;
                display: inline-block;
            }
            
            .dropdown-content {
            	margin-left:6px;
                display: none;
                position: absolute;
                background-color: #f1f1f1;
                min-width: 80px;
                overflow: auto;
                box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
                z-index: 1;
            }
            
            .dropdown-content a {
                color: black;
                padding: 10px 10px;
                text-decoration: none;
                display: block;
            }
            
            .dropdown a:hover {background-color: #ddd;}
            
            .show {display: block;}
        </style>

    </head>
    
    <body>

        <div class="container">
        <div id="result"></div>
        <div id="activitystream" style="padding:15px;">
            <?php
                $resultstatus=$objstatus->salesselectstatus();
                $resulttag=$objtag->salesselecttag();
                $resultemployee=$objemployee->salesselectemployee();
                $resultleadsource=$objleadsource->salesselectleadsource();
                ?>
            <div class="divshowmoreaction" style="display:none">
                <input type="hidden" id="myDropdownstatusinput" value="0">
                <input type="hidden" id="myDropdowntaginput" value="0">
                <input type="hidden" id="myDropdownownerinput" value="0">
                <input type="hidden" id="myDropdownleadinput" value="0">
                <input type="hidden" id="myDropdownmoreinput" value="0">
                    <button onclick="myFunctiondelete()" class="dropbtn"><i class="fa fa-trash-o"></i></button>
                <div class="dropdown">
                    <button onclick="myFunctionstatus()" class="dropbtn">Status<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownstatus" class="dropdown-content">
                        <?php
                        foreach($resultstatus as $rowstatus){
                            $statusid=$rowstatus['id'];
                            $statusname=$rowstatus['status_name'];
                        ?>
                        <a onclick="funchangestatusdb('<?php echo $statusid;?>')"><?php echo $statusname;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctiontag()" class="dropbtn">Tag<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdowntag" class="dropdown-content">
                        <?php
                        foreach($resulttag as $rowtag){
                            $tagid=$rowtag['id'];
                            $tagname=$rowtag['tag_name'];
                        ?>
                        <a onclick="funchangetagdb('<?php echo $tagid;?>')"><?php echo $tagname;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctionowner()" class="dropbtn">Owner<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownowner" class="dropdown-content">
                        <?php
                        foreach($resultemployee as $rowemployee){
                            $employeeid121313=$rowemployee['emailid'];
                            $employeename=$rowemployee['employeename'];
                        ?>
                        <a onclick="funchangeemployeedb('<?php echo $employeeid121313;?>')"><?php echo $employeename;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctionlead()" class="dropbtn">Lead<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownlead" class="dropdown-content">
                        <?php
                        foreach($resultleadsource as $rowleadsource){
                            $leadsourceid=$rowleadsource['id'];
                            $leadsourcename=$rowleadsource['lead_name'];
                        ?>
                        <a onclick="funchangeleadsourcedb('<?php echo $leadsourceid;?>')"><?php echo $leadsourcename;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctionaction()" class="dropbtn" data-toggle="modal" data-target="#myModal">Action</button>
                </div>
                <!--<div class="dropdown">
                    <button onclick="myFunctionmore()" class="dropbtn">More<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownmore" class="dropdown-content">
                        <a href="#home">Home</a>
                        <a href="#about">About</a>
                        <a href="#contact">Contact</a>
                    </div>
                </div>-->
            </div>
            <div class="row" style="padding-bottom:10px;">
                
                <span class="bulk_select select_all">
                <input type="checkbox" class="allcheckbox" name="allcheckbox" id="allcheckbox" style="margin-left:25px" value="bulk_select" autocomplete="off">
                </span>
                <span class="contact_org" style="margin-left:50px;">
                <a class="show_contacts white-green-btn selected"><i class="fa fa-user"></i></a>
                <a class="show_companies white-grey-btn" onclick="gotoorg()" style="cursor:pointer;"><i class="fa fa-building"></i></a>
                
                </span>
        
                <span class="pull-right">
                    <ul id="letters" class="option-set letters-list">
                        <li><a  onclick="showcontactfunc('All')">All</a></li>
                        <li><a onclick="showcontactfunc('1')" style="cursor:pointer;" class="alphabet letter_1 inactive">1</a></li>
                        <li><a onclick="showcontactfunc('A')" style="cursor:pointer;" class="alphabet letter_a inactive">a</a></li>
                        <li><a onclick="showcontactfunc('B')" style="cursor:pointer;" class="alphabet letter_b inactive">b</a></li>
                        <li><a onclick="showcontactfunc('C')" style="cursor:pointer;" class="alphabet letter_c inactive">c</a></li>
                        <li><a onclick="showcontactfunc('D')" style="cursor:pointer;" class="alphabet letter_d inactive">d</a></li>
                        <li><a onclick="showcontactfunc('E')" style="cursor:pointer;" class="alphabet letter_e inactive">e</a></li>
                        <li><a onclick="showcontactfunc('F')" style="cursor:pointer;" class="alphabet letter_f inactive">f</a></li>
                        <li><a onclick="showcontactfunc('G')" style="cursor:pointer;" class="alphabet letter_g inactive">g</a></li>
                        <li><a onclick="showcontactfunc('H')" style="cursor:pointer;" class="alphabet letter_h inactive">h</a></li>
                        <li><a onclick="showcontactfunc('I')" style="cursor:pointer;" class="alphabet letter_i inactive">i</a></li>
                        <li><a onclick="showcontactfunc('J')" style="cursor:pointer;" class="alphabet letter_j inactive">j</a></li>
                        <li><a onclick="showcontactfunc('K')" style="cursor:pointer;" class="alphabet letter_k inactive">k</a></li>
                        <li><a onclick="showcontactfunc('L')" style="cursor:pointer;" class="alphabet letter_l inactive">l</a></li>
                        <li><a onclick="showcontactfunc('M')" style="cursor:pointer;" class="alphabet letter_m inactive">m</a></li>
                        <li><a onclick="showcontactfunc('N')" style="cursor:pointer;" class="alphabet letter_n inactive">n</a></li>
                        <li><a onclick="showcontactfunc('O')" style="cursor:pointer;" class="alphabet letter_o inactive">o</a></li>
                        <li><a onclick="showcontactfunc('P')" style="cursor:pointer;" class="alphabet letter_p inactive">p</a></li>
                        <li><a onclick="showcontactfunc('Q')" style="cursor:pointer;" class="alphabet letter_q inactive">q</a></li>
                        <li><a onclick="showcontactfunc('R')" style="cursor:pointer;" class="alphabet letter_r inactive">r</a></li>
                        <li><a onclick="showcontactfunc('S')" style="cursor:pointer;" class="alphabet letter_s inactive">s</a></li>
                        <li><a onclick="showcontactfunc('T')" style="cursor:pointer;" class="alphabet letter_t inactive">t</a></li>
                        <li><a onclick="showcontactfunc('U')" style="cursor:pointer;" class="alphabet letter_u inactive">u</a></li>
                        <li><a onclick="showcontactfunc('V')" style="cursor:pointer;" class="alphabet letter_v inactive">v</a></li>
                        <li><a onclick="showcontactfunc('W')" style="cursor:pointer;" class="alphabet letter_w inactive">w</a></li>
                        <li><a onclick="showcontactfunc('X')" style="cursor:pointer;" class="alphabet letter_x inactive">x</a></li>
                        <li><a onclick="showcontactfunc('Y')" style="cursor:pointer;" class="alphabet letter_y inactive">y</a></li>
                        <li><a onclick="showcontactfunc('Z')" style="cursor:pointer;" class="alphabet letter_z inactive">z</a></li>
                    </ul>
                </span>
            </div>
                   	
<?php
$resultcontact=$objcontact->sales_select_contact_alphabet($companyname,$adminemailid);
//print_r($resultcontact);
$totalcount_star=$resultcontact->rowcount();
if($totalcount_star==0){
?>
<div style="padding-top:70px;">
    <center>
        Please Create New Contact<br>
        <span style="color:#1f79f2;cursor:pointer;" onclick="location.replace('addcontact.php')">Add Contact</span>
    </center>
</div>
<?php
}else{
$check_letter="123213131";
$firstletter_in_array=array();
$cont_id_array=array();
foreach($resultcontact as $rowcontact){
    $cont_id=$rowcontact['cont_id'];
    array_push($cont_id_array,$cont_id);
    $cont_name_title="";
    $cont_name_title=$rowcontact['cont_name_title'];
    $cont_first_name="";
    $cont_first_name=$rowcontact['cont_first_name'];
    $cont_last_name="";
    $cont_last_name=$rowcontact['cont_last_name'];
    $cont_job_title="";
    $cont_job_title=$rowcontact['cont_job_title'];
    $cont_address_line="";
    $cont_address_line=$rowcontact['cont_address_line'];
    $cont_address_city="";
    $cont_address_city=$rowcontact['cont_address_city'];
    $cont_address_state="";
    $cont_address_state=$rowcontact['cont_address_state'];
    $cont_address_country="";
    $cont_address_country=$rowcontact['cont_address_country'];
    $cont_address_pincode="";
    $cont_address_pincode=$rowcontact['cont_address_pincode'];
    $cont_status="";
    $cont_status=$rowcontact['cont_status'];
    $cont_tag="";
    $cont_tag=$rowcontact['cont_tag'];
    $cont_lead_source="";
    $cont_lead_source=$rowcontact['cont_lead_source'];
    $cont_background="";
    $cont_background=$rowcontact['cont_background'];
    $cont_owner="";
    $cont_owner=$rowcontact['cont_owner'];
    $cont_make_private="";
    $cont_make_private=$rowcontact['cont_make_private'];
    $cont_birthdate="";
    $cont_birthdate=$rowcontact['cont_birthdate'];
    $cont_datetime="";
    $cont_datetime=$rowcontact['cont_datetime'];
    $cont_star=$rowcontact['cont_star'];
    
    $org_id=$rowcontact['org_id'];
    $org_name=$rowcontact['org_name'];
    $org_desc=$rowcontact['org_desc'];
    $org_phone=$rowcontact['org_phone'];
    $org_url=$rowcontact['org_url'];
    $org_add=$rowcontact['org_add'];
    $org_city=$rowcontact['org_city'];
    $org_state=$rowcontact['org_state'];
    $org_country=$rowcontact['org_country'];
    $org_pincode=$rowcontact['org_pincode'];
    $org_created_by=$rowcontact['org_created_by'];
    $org_created_type=$rowcontact['org_created_type'];
    $org_datetime=$rowcontact['org_datetime'];
    
    $first_letter=strtoupper($cont_last_name[0]);
    if($first_letter==""){
        $first_letter="1";
    }
    if($check_letter!=$first_letter){
        $check_letter=$first_letter;
        array_push($firstletter_in_array, $check_letter);
    ?>
        <div class="row header-letter show_header_<?php echo $first_letter;?>" style="cursor:pointer;" onclick="showcontactfunc('<?php echo $first_letter;?>')">
            <div ><?php echo $first_letter;?></div>
        </div>
    <?php
    }
    ?>
            <div class="row body-letter show_body_<?php echo $first_letter;?>">
                <div class="col-xs-1">
                    <input type="checkbox" class="checkall" name="cont_check_<?php echo $cont_id;?>" id="cont_check_<?php echo $cont_id;?>" onclick="checkboxckecking('<?php echo $cont_id;?>','cont_check_<?php echo $cont_id;?>')" autocomplete="off">
                    &nbsp;&nbsp;<span id="star_<?php echo $cont_id;?>" onclick="funcstar('<?php echo $cont_star;?>','<?php echo $cont_id;?>','#star_<?php echo $cont_id;?>')" style="color:<?php if($cont_star==0){ echo 'black'; }else{ echo 'orange'; }?>"><i class="fa fa-star"></i></span>
                </div>
                <div class="col-xs-5 rowaction"  style="cursor:pointer;" onclick="showcontactionformation('<?php echo $cont_id;?>')">
                    
                    <span>
                        &nbsp;&nbsp;<?php echo $cont_first_name." ".$cont_last_name;?>
                        <span style="color:grey;overflow: hidden;white-space: nowrap;Text-overflow:ellipsis;" title="<?php echo $org_name;?>"><b><?php echo $org_name;?></b></span>
                    </span>
                </div>
                <div class="col-xs-3" style="cursor:pointer;" onclick="showcontactionformation('<?php echo $cont_id;?>')">
                                                      
<?php
    
$resultphone=$objsales->salesselectcontid("sales_phone", $cont_id);
//print_r($resultorganization);
$s_phone_number_array=array();
$s_phone_type_array=array();
foreach($resultphone as $rowphone){
$s_phone_number=$rowphone['phone_number'];
array_push($s_phone_number_array, $s_phone_number);
$s_phone_type=$rowphone['phone_type'];
array_push($s_phone_type_array, $s_phone_type);
}
if(count($s_phone_number_array)!=0){
    if(count($s_phone_number_array)==1){
        echo "<i class='fa fa-phone' aria-hidden='true'></i>&nbsp;".$s_phone_number_array[0];
    }else{
    ?>
    <i class="fa fa-phone" aria-hidden="true"></i>&nbsp;
    <select id="phone_<?php echo $cont_id;?>" style="border:none;background-color: #f0f0f0;">
        <option value="<?php echo $s_phone_number_array[0];?>"><?php echo $s_phone_number_array[0];?></option>
        <?php
        for($jkd=1;$jkd<count($s_phone_number_array);$jkd++){
        ?>
        <option value="<?php echo $s_phone_number_array[$jkd];?>"><?php echo $s_phone_number_array[$jkd];?></option>
        <?php
        }
        ?>
    </select>
    <?php
    }
}
?>

                </div>
                <div class="col-xs-3" style="cursor:pointer;" onclick="showcontactionformation('<?php echo $cont_id;?>')">
<?php    
$result_email=$objsales->salesselectcontid("sales_email", $cont_id);
$email_name_array=array();
$email_type_array=array();
foreach($result_email as $row_email){
$email_name=$row_email['email_name'];
array_push($email_name_array, $email_name);
$email_type=$row_email['email_type'];
array_push($email_type_array, $email_type);
}
if(count($email_name_array)!=0){
    if(count($email_name_array)==1){
        echo "<i class='fa fa-envelope' aria-hidden='true'></i>&nbsp;".$email_name_array[0];
    }else{
    ?>
    <i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;
    <select id="phone_<?php echo $cont_id;?>" style="border:none;background-color: #f0f0f0;">
        <option value="<?php echo $email_name_array[0];?>"><?php echo $email_name_array[0];?></option>
        <?php
        for($jkd=1;$jkd<count($email_name_array);$jkd++){
        ?>
        <option value="<?php echo $email_name_array[$jkd];?>"><?php echo $email_name_array[$jkd];?></option>
        <?php
        }
        ?>
    </select>
    <?php
    }
}
?>
                </div>
        
            </div>
                  
        	
<?php    
}
}
?>

<input type="hidden" id="check_cont">

<style>
    .header-letter {
        clear: both;
        background-color: #f0ffd1;
        padding: 3px 10px;
        border-top: 1px solid #fff;
        border-bottom: 3px solid #fff;
    }
    .body-letter {
        clear: both;
        background-color: #f0f0f0;
        padding: 3px 10px;
        border-top: 1px solid #fff;
        border-bottom: 3px solid #fff;
    }
    </style>
    
    <script>
    $(document).ready(function(){
        var firstletter=<?php echo json_encode($firstletter_in_array);?>;
        for(var f=0;f<firstletter.length;f++){
             var l=firstletter[f];
             var id1=".letter_"+l;
            $(id1).removeClass("inactive");
        }
    });
    </script>
    <script>
        function showcontactfunc(letter){
            var firstletter=<?php echo json_encode($firstletter_in_array);?>;
            if(letter=="All"){
                for(var f=0;f<firstletter.length;f++){
                     var l=firstletter[f];
                     var id1=".show_body_"+l;
                    $(id1).show();
                     var id1=".show_header_"+l;
                    $(id1).show();
                }
            }else if(firstletter.indexOf(letter)<0){
                
            }else{
                for(var f=0;f<firstletter.length;f++){
                     var l=firstletter[f];
                     var id1=".show_body_"+l;
                    $(id1).hide();
                     var id1=".show_header_"+l;
                    $(id1).hide();
                }
                 var id1=".show_body_"+letter;
                $(id1).show();
                 var id1=".show_header_"+letter;
                $(id1).show();
            }
        }
    </script>
    
    
        <script> 
            function showcontactionformation(value){
                var cont_id=<?php echo json_encode($cont_id_array);?>;
                var page="contactlist.php";
                $.ajax({
                   url: "show_contact_activity2.php",
                   method: "post",
                   data:{value:value, cont_id:cont_id, page:page},
                   success:function(response){
                       $("#activitystream").hide();
                       $("#result").html("");
                       $("#result").html(response);
                       $("#result").show();
                                    
                   }
                });
            }
        </script>   
        <script>
            $(document).on("click", ".allcheckbox", function(){
                var cont_id=<?php echo json_encode($cont_id_array);?>;
                var check_cont="";
                if($('.allcheckbox').is(':checked')){
                    for(var f=0;f<cont_id.length;f++){
                        var l=cont_id[f];
                        var id1="#cont_check_"+l;
                        $(id1).prop("checked", true);
                        
                        if(check_cont==""){
                            check_cont=cont_id[f];
                        }else{
                            check_cont+="@#"+cont_id[f];
                        }
                    }
                    $(".divshowmoreaction").show();
                    
                    
                }else{
                    for(var f=0;f<cont_id.length;f++){
                         var l=cont_id[f];
                         var id1="#cont_check_"+l;
                        $(id1).prop("checked", false);
                    }
                    $(".divshowmoreaction").hide();
                }
                $("#check_cont").val(check_cont);
            });
        </script>
        
    
        <script>
            function funcstar(value, cid, id){
                if(value==0){
                    var value1=1;
                    $(id).css({ 'color': 'Orange'});
                    $.ajax({
                       url: "../Control/contact.php",
                       method: "post",
                       data:{staron:value1, cont_id:cid},
                       success:function(response){
                        swal("","This Contact marked as star", "success");
                       }
                    });
                }else{
                    var value1=0;
                    $(id).css({ 'color': 'black'});
                    $.ajax({
                       url: "../Control/contact.php",
                       method: "post",
                       data:{staroff:value1, cont_id:cid},
                       success:function(response){
                            swal("","This Contact unmarked as star", "success");
                       }
                    });
                }
                 
            }
        </script>
        
        <script>
            /* When the user clicks on the button, 
            toggle between hiding and showing the dropdown content */
            function myFunctionstatus() {
                var value1=$("#myDropdownstatusinput").val();
                if(value1==0){
                    $("#myDropdownstatus").show();
                    $("#myDropdownstatusinput").val(1);
                    $("#myDropdowntaginput").val(0);
                    $("#myDropdownownerinput").val(0);
                    $("#myDropdownleadinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdownstatus").hide();
                    $("#myDropdownstatusinput").val(0);
                }
                $("#myDropdowntag").hide();
                $("#myDropdownowner").hide();
                $("#myDropdownlead").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctiontag() {
                var value1=$("#myDropdowntaginput").val();
                if(value1==0){
                    $("#myDropdowntag").show();
                    $("#myDropdowntaginput").val(1);
                    $("#myDropdownstatusinput").val(0);
                    $("#myDropdownownerinput").val(0);
                    $("#myDropdownleadinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdowntag").hide();
                    $("#myDropdowntaginput").val(0);
                }
                $("#myDropdownstatus").hide();
                $("#myDropdownowner").hide();
                $("#myDropdownlead").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctionowner() {
                var value1=$("#myDropdownownerinput").val();
                if(value1==0){
                    $("#myDropdownowner").show();
                    $("#myDropdownownerinput").val(1);
                    $("#myDropdownstatusinput").val(0);
                    $("#myDropdowntaginput").val(0);
                    $("#myDropdownleadinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdownowner").hide();
                    $("#myDropdownownerinput").val(0);
                }
                $("#myDropdownstatus").hide();
                $("#myDropdowntag").hide();
                $("#myDropdownlead").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctionlead() {
                var value1=$("#myDropdownleadinput").val();
                if(value1==0){
                    $("#myDropdownlead").show();
                    $("#myDropdownleadinput").val(1);
                    $("#myDropdownstatusinput").val(0);
                    $("#myDropdowntaginput").val(0);
                    $("#myDropdownownerinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdownlead").hide();
                    $("#myDropdownleadinput").val(0);
                }
                $("#myDropdownstatus").hide();
                $("#myDropdowntag").hide();
                $("#myDropdownowner").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctionaction(){
                $("#myDropdownleadinput").val(0);
                $("#myDropdownstatusinput").val(0);
                $("#myDropdowntaginput").val(0);
                $("#myDropdownownerinput").val(0);
                
                $("#myDropdownlead").hide();
                $("#myDropdownstatus").hide();
                $("#myDropdowntag").hide();
                $("#myDropdownowner").hide();
                //$("#myDropdownmore").hide();
            }
            
            // Close the dropdown if the user clicks outside of it
            window.onclick = function(event) {
              if (!event.target.matches('.dropbtn')) {
            
                var dropdowns = document.getElementsByClassName("dropdown-content");
                var i;
                for (i = 0; i < dropdowns.length; i++) {
                  var openDropdown = dropdowns[i];
                  if (openDropdown.classList.contains('show')) {
                    openDropdown.classList.remove('show');
                  }
                }
              }
            }
        </script>
        <script>
            function checkboxckecking(value1, id){
                var check_cont=$("#check_cont").val();
                if($("#"+id).is(':checked')){
                    $(".divshowmoreaction").show();
                    if(check_cont==""){
                        check_cont=value1;
                    }else{
                        check_cont+="@#"+value1;
                    }
                    $("#check_cont").val(check_cont);
                }else{
                    var pass="";
                    var result =new Array();
                    result=check_cont.split("@#");
                    for(var i=0;i<result.length;i++){
                        if(value1!=result[i]){
                            if(pass==""){
                                pass=result[i];
                            }else{
                                pass+="@#"+result[i];
                            }
                        }
                    }
                    if(pass==""){
                    $(".divshowmoreaction").hide();
                    }
                    $("#check_cont").val(pass);
                }
                checkcheckbox();
            }
        </script>
        <script>
            function checkcheckbox(){
                var cont_id=<?php echo json_encode($cont_id_array);?>;
                var somethingChecked = false;
                $("input[type=checkbox]").each(function() {
                  if(this).is(':checked')) {
                    somethingChecked = true;
                  }
                });
                if(!somethingChecked) {
                    $(".divshowmoreaction").hide();
                }else{
                    $(".divshowmoreaction").show();
                }
            }
        </script>
        <script>
            function funchangestatusdb(statusid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/status.php",
                   method: "post",
                   data:{updatestatus:statusid, cont:cont1},
                   success:function(response){
                        window.location.replace("contactlist.php");
                   }
                });
            }
        </script>
        <script>
            function funchangetagdb(tagid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/tag.php",
                   method: "post",
                   data:{updatetag:tagid, cont:cont1},
                   success:function(response){
                        window.location.replace("contactlist.php");
                   }
                });
            }
        </script>
        <script>
            function funchangeemployeedb(employeeid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/employee.php",
                   method: "post",
                   data:{updateemployee:employeeid, cont:cont1},
                   success:function(response){
                        window.location.replace("contactlist.php");
                   }
                });
            }
        </script>
        <script>
            function funchangeleadsourcedb(leadsourceid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/leadsource.php",
                   method: "post",
                   data:{updateleadsource:leadsourceid, cont:cont1},
                   success:function(response){
                        window.location.replace("contactlist.php");
                   }
                });
            }
        </script>
        </div>  
        
        </div>
        
        
        
        
          <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        
        <div class="modal-body">
            <h4 class="modal-title">Bulk set action<span class="pull-right"><button type="button" class="close" data-dismiss="modal">&times;</button></span></h4>
            <div class="row" style="padding:10px;">
                <div style="padding:20px;background-color:#d9eefc;">
                    Next Action:
                    <input type="text" class="form-control" id="nextactionname"><br>
                    <select name="selectdate" id="selectdate" style="padding: 5px;border-radius: 5px;">
                        <option value="Date" selected>Date</option>
                        <option value="ASAP">ASAP</option>
                        <option value="Waiting for">Waiting for</option>
                        <option value="" disabled><b>Quick Date</b></option>
                        <option value="Tomorrow">&nbsp;&nbsp;Tomorrow</option>
                        <option value="7 days time">&nbsp;&nbsp;7 days time</option>
                        <option value="2 Weeks time">&nbsp;&nbsp;2 Weeks time</option>
                        <option value="30 days time">&nbsp;&nbsp;30 days time</option>
                    </select>
                    <input type="text" name="nextactiondate" id="nextactiondate" readonly style="padding: 5px;border-radius: 5px;" >
                    <?php
                    $resultemployee=$objemployee->salesselectemployee();
                    ?>
                    <span class="pull-right">
                        <select id="nextactionowner" name="nextactionowner" style="padding: 5px;border-radius: 5px;">
                            <?php
                            foreach($resultemployee as $rowemployee){
                                $employeeid121313=$rowemployee['emailid'];
                                $employeename=$rowemployee['employeename'];
                                if($employeeid121313==$createby){
                                ?>
                                <option value="<?php echo $employeeid121313;?>" selected style="padding: 5px;">me(<?php echo $employeename;?>)</option>
                                <?php
                                }else{
                                ?>
                                <option value="<?php echo $employeeid121313;?>" style="padding: 5px;"><?php echo $employeename;?></option>
                                <?php
                                }
                            }
                            ?>
                        </select>
                    </span>
                </div>
            </div>
            
            <input type="button" value="Save" class="btn btn-primary" id="addnextactionformulitple">
            <input type="button" value="Cancel" class="btn btn-default" data-dismiss="modal">
        </div>
        
      </div>
      
    </div>
  </div>
  
<script>
 $( function() {
    var tomorrow = new Date();
    var d=tomorrow.getDate();
    var m=tomorrow.getMonth();
    var y=tomorrow.getFullYear();
    if(d<10){
        d="0"+d;
    }
    if(m<10){
        m1=m+1;
        m="0"+m1;
    }
    var datee=y+"-"+m+"-"+d;
    var datee1=d+"-"+m+"-"+y;
    $("#nextactiondate").val(datee);
    $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
 } );
</script>
<script>
    $(document).on("change", "#selectdate", function(){
        var selectdate=$("#selectdate").val();
        var tomorrow = new Date();
        if(selectdate=="Date"){
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
        }else if(selectdate=="ASAP"){
            $( "#nextactiondate").hide();
            //$( "#nextactiondate").datepicker();
        }else if(selectdate=="Waiting for"){
            $( "#nextactiondate").hide();
            //$( "#nextactiondate").datepicker();
        }else if(selectdate=="Tomorrow"){
            tomorrow.setDate(tomorrow.getDate() + 1);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
        }else if(selectdate=="7 days time"){
            tomorrow.setDate(tomorrow.getDate() + 7);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
        }else if(selectdate=="2 Weeks time"){
            tomorrow.setDate(tomorrow.getDate() + 14);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
        }else if(selectdate=="30 days time"){
            tomorrow.setDate(tomorrow.getDate() + 30);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
            /*
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ dateFormat: 'yy-mm-dd', setDate: datee} );*/
        }
    });
 </script>
<script>
    $(document).on("click", "#addnextactionformulitple", function(){
        var nextactionname=$("#nextactionname").val();
        if(nextactionname==""){
            swal("","Please Enter Next Action", "success");
            $("#nextactionname").focus();
        return;
        }
        var nextactionowner=$("#nextactionowner").val();
        if(nextactionowner==""){
            swal("","Please Select Next Action done", "success");
            $("#nextactionowner").focus();
        return;
        }
        var na_assign=$("#nextactionowner").val();
        var na_descr=$("#nextactionname").val();
        var na_selectedoption=$("#selectdate").val();
        var na_date="";
        if((na_selectedoption!="ASAP")&&(na_selectedoption!="Waiting for")){
            na_date=$("#nextactiondate").val();
        }
        var cont1=$("#check_cont").val();
        $.ajax({
           url: "../Control/nextaction.php",
           method: "post",
           data:{insertnextactionmultiple:na_descr, cont:cont1, na_assign:na_assign, na_selectedoption:na_selectedoption, na_date:na_date},
           success:function(response){
                window.location.replace("contactlist.php");
           }
        });
    });
</script>
 
        <script>
            function myFunctiondelete(){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/contact.php",
                   method: "post",
                   data:{deletecontact:cont1},
                   success:function(response){
                        window.location.replace("contactlist.php");
                   }
                });
            }
        </script>
    </body>
    
</html>