<?php
session_start();
$companyname="Webtech sales";//$_SESSION['companyname'];
$adminemailid="velemailid@gmail.com";//$_SESSION['emailid'];
$cont_id="G_G_6";
require_once('../Control/address.php');
$objaddress=new addressctrl();
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/contact.php');
$objcontact=new contactctrl();
/*if(isset($_POST['value'])){
    $cid=$_POST['value'];
    $cont_id=$_POST['cont_id'];
    //echo $c_id;
}*/
$i=0;
$result_status=$objsales->salesselectall($companyname, $adminemailid, "signupdetails", "no");
$emailid1=array();
$employeename1=array();
foreach($result_status as $row_status){
    $emailid1[$i]=$row_status['emailid'];
    $employeename1[$i]=$row_status['employeename'];
    $i++;
}
$k=0;

$result_pipe=$objsales->salesselectall($companyname, $adminemailid, "sales_pipe_type", "no");
$pipe_id=array();
$pipe_name=array();
$pipe_percentage=array();
foreach($result_pipe as $row_pipe){
    $pipe_id[$k]=$row_pipe['id'];
    $pipe_name[$k]=$row_pipe['pipe_name'];
    $pipe_percentage[$k]=$row_pipe['pipe_percentage'];
    $k++;
}
$k1=0;

$result_call_ans=$objsales->salesselectall($companyname, $adminemailid, "sales_call_answer_type", "no");
$c_ans_id_a=array();
$c_ans_name_a=array();
foreach($result_call_ans as $row_call_ans){
    $c_ans_id_a[$k1]=$row_call_ans['id'];
    $c_ans_name_a[$k1]=$row_call_ans['c_ans_name'];
    $k1++;
}


for($kk=0;$kk<count($emailid1);$kk++){
    $emailid11=$emailid1[$kk];
    $employeename11=$employeename1[$kk];
    if($emailid11==$c_owner_id){
        $c_owner_name=$employeename11;
    }
}


for($i=0;$i<count($cont_id);$i++){
    $c_id=$cont_id[$i];
        if($cid==$c_id){
            break;
        }
}


$result_contact=$objsales->salesselectedid("viewcontact", $c_id);
foreach($result_contact as $row_contact){
    $c_companyname=$row_contact['c_companyname'];
    $c_emailid=$row_contact['c_emailid'];
    $c_delete=$row_contact['c_delete']; 
    $c_id=$row_contact['c_id'];
    $c_title=$row_contact['c_title'];
    $c_fname=$row_contact['c_fname'];
    $c_lname=$row_contact['c_lname'];
    $c_jobtitle=$row_contact['c_jobtitle'];
    $c_a_line=$row_contact['c_a_line'];
    $c_a_city=$row_contact['c_a_city'];
    $c_a_state=$row_contact['c_a_state'];
    $c_a_country=$row_contact['c_a_country'];
    $c_a_pincode=$row_contact['c_a_pincode'];
    $c_background=$row_contact['c_background'];
    $c_owner_id=$row_contact['c_owner_id'];
    $c_private=$row_contact['c_private'];
    $c_dob=$row_contact['c_dob'];
    $c_dtime=$row_contact['c_dtime'];
    $c_create_by=$row_contact['c_create_by'];
    $c_create_type=$row_contact['c_create_type'];
    $o_id=$row_contact['o_id'];
    $o_name=$row_contact['o_name'];
    $o_desc=$row_contact['o_desc'];
    $o_phone=$row_contact['o_phone'];
    $o_url=$row_contact['o_url'];
    $o_line=$row_contact['o_line'];
    $o_city=$row_contact['o_city'];
    $o_state=$row_contact['o_state'];
    $o_country=$row_contact['o_country'];
    $o_pincode=$row_contact['o_pincode'];
    $o_create_by=$row_contact['o_create_by'];
    $o_create_type=$row_contact['o_create_type'];
    $s_name=$row_contact['s_name'];
    $s_desc=$row_contact['s_desc'];
    $s_color=$row_contact['s_color'];
    $t_name=$row_contact['t_name'];
    $t_desc=$row_contact['t_desc'];
    $l_name=$row_contact['l_name'];
    $status_id=$row_contact['status_id']; 
    $tag_id=$row_contact['tag_id']; 
    $lead_id=$row_contact['lead_id']; 
    $c_code=$row_contact['c_code'];
    $cont_imagepath=$row_contact['cont_imagepath'];
    $nastatus=$row_contact['nastatus'];
    $closingcomment=$row_contact['closingcomment'];
    $closingdate=$row_contact['closingdate'];
    $viewrowid="viewcontact".$c_id;
    $viewrowid1="#viewcontact".$c_id;
    $value=$c_companyname."#@".$c_emailid."#@".$c_id."#@".$c_title."#@".$c_fname."#@".$c_lname."#@".$c_jobtitle."#@".$c_a_line."#@".$c_a_city."#@".$c_a_state."#@".$c_a_country."#@".$c_a_pincode."#@".$c_background."#@".$c_owner_id."#@".$c_private."#@".$c_dob."#@".$c_dtime."#@".$c_create_by."#@".$c_create_type."#@".$o_id."#@".$o_name."#@".$o_desc."#@".$o_phone."#@".$o_url."#@".$o_line."#@".$o_city."#@".$o_state."#@".$o_country."#@".$o_pincode."#@".$o_create_by."#@".$o_create_type."#@".$s_name."#@".$s_desc."#@".$s_color."#@".$t_name."#@".$t_desc."#@".$l_name."#@".$c_delete."#@".$status_id."#@".$tag_id."#@".$lead_id;
    //echo $value;
}

?>
<style>

.dropdown, .dropdown-toggle{
border:0px;
}

.dropdown a:hover {background-color: white;}


.add_new_action {
    background: url(../../Images/add_delete.png) no-repeat -35px -94px transparent;
    width: 17px;
    height: 17px;
    display: block;
    position: absolute;
    content: "";
    display: block;
    text-indent: -9999px;
    cursor: pointer;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    position: static;
}
</style>  

<style>
    input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0; 
}
</style>

<!-- 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>
            
<div class="showcontactidbyid<?php echo $c_id;?>" style="padding:0px 20px;">
    <div class="row" style="background-color:#f0f0f0;padding:0px;cursor:pointer;">
        <span class="btn btn-default" onclick="backcontact()"><span style=" transform: rotate(180deg);" class="glyphicon glyphicon-share-alt"></span></span>
        <span class="pull-right">
            <?php if($i==0){ ?>
            <span class="btn btn-default" style="display:none;" onclick="beforedata('<?php echo $beforeid;?>','<?php echo $afterid;?>','<?php echo $current;?>')"><i class="fa fa-chevron-up"></i></span>
            <span class="btn btn-default"  onclick="viewcontact('<?php echo $cont_id[$i+1];?>')"><i class="fa fa-chevron-down"></i></span>
            <?php }else if($i==(count($cont_id)-1)){ ?>
            <span class="btn btn-default" onclick="viewcontact('<?php echo $cont_id[$i-1];?>')"><i class="fa fa-chevron-up"></i></span>
            <span class="btn btn-default" style="display:none;" onclick="afterdata('<?php echo $beforeid;?>','<?php echo $afterid;?>','<?php echo $current;?>')"><i class="fa fa-chevron-down"></i></span>
            <?php }else{ ?>
            <span class="btn btn-default" onclick="viewcontact('<?php echo $cont_id[$i-1];?>')"><i class="fa fa-chevron-up"></i></span>
            <span class="btn btn-default"  onclick="viewcontact('<?php echo $cont_id[$i+1];?>')"><i class="fa fa-chevron-down"></i></span>
            <?php } ?>
        </span>
    </div>
    
    
                <div class="row">
                    <div class="col-md-2">
                        
                        <div class="image-upload">
                            <label for="file-input">
                                <img src="<?php echo $cont_imagepath;?>" width="100%" height="auto" style="z-index:1;cursor:pointer"/>
                            </label>
                            <input id="file-input" type="file" onchange="functionupload()"  style="z-index:2;margin-top:-35px;" accept="image/png, image/jpeg, image/jpg">
                        </div>
                    </div>
                    <div class="col-md-10">
                        <b><span style="fornt-size:2em;"><?php echo $c_title."&nbsp;".$c_fname."&nbsp;".$c_lname;?></span></b><i class="fa fa-star" aria-hidden="true"></i>
                        <span class="pull-right" style="color:grey;cursor:pointer;" onclick="functioneditcontact('<?php echo $c_id;?>','activestream_list_view1.php')"><i class="glyphicon glyphicon-pencil"></i>&nbsp;Edit</span>
                        <br>
                        <?php echo $o_name;?>.&nbsp;&nbsp;&nbsp;&nbsp;<span class="btn btn-default"><i class="fa fa-building-o fa-lg" aria-hidden="true"></i><i class="fa fa-building-o" aria-hidden="true"></i>&nbsp;<i class="fa fa-angle-down" aria-hidden="true"></i></span>
                        <br>
                        <?php
                        $result_phone=$objsales->salesselectcontid("sales_phone", $c_id);
                        foreach($result_phone as $row_phone){
                            $phone_number=$row_phone['phone_number'];
                            $phone_type=$row_phone['phone_type'];
                            
                            ?>
                            <b>+<?php echo $c_code;?>&nbsp;<?php echo $phone_number;?></b> &nbsp;&nbsp;<span style="color:grey;"><?php echo $phone_type;?></span><br>
                            <?php
                        }
                        $result_email=$objsales->salesselectcontid("sales_email", $c_id);
                        foreach($result_email as $row_email){
                            $email_name=$row_email['email_name'];
                            ?>
                            <span style="color:#6699cc;"><?php echo $email_name;?></span><br>
                            <?php
                        }
                        $result_url=$objsales->salesselectcontid("sales_url", $c_id);
                        foreach($result_url as $row_url){
                            $url_name=$row_url['url_name'];
                            ?>
                            <span style="color:#6699cc;"><?php echo $url_name;?></span><br>
                            <?php
                        }
                        ?>
                    </div>
                </div>
</div>