<link href="<?php echo THEME_PATH; ?>css/pipeline.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo THEME_PATH; ?>js/general.js"></script>
<script src="<?php echo VIEWS_PATH; ?>crm/common.js"></script>
<link href="<?php echo THEME_PATH; ?>css/crm-profile.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo THEME_PATH; ?>js/jquery.timeago.min.js"></script>
<link href="<?php echo THEME_PATH; ?>plugins/icheck/icheck.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo THEME_PATH; ?>plugins/icheck/icheck.min.js" type="text/javascript"></script>
<link href='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/core/main.css' rel='stylesheet' />
<link href='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/daygrid/main.css' rel='stylesheet' />
<link href='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/timegrid/main.css' rel='stylesheet' />
<link href='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/list/main.css' rel='stylesheet' />
<script src='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/core/main.js'></script>
<script src='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/interaction/main.js'></script>
<script src='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/daygrid/main.js'></script>
<script src='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/timegrid/main.js'></script>
<script src='<?php echo THEME_PATH; ?>plugins/fullcalendar-4.2.0/packages/list/main.js'></script>
<style>
    input[type=checkbox]{
        display:initial !important;
    }
    .blue-span{
        color:#ffffff;
    }
</style>
<div class="page-inner">
    <div id="main-wrapper">
        <form id="formdeal2">
            <input type="hidden" id="org_id" name="id" value="<?php echo $customer['organization_id'];?>">
            <input type="hidden" id="current_organization_name" name="owner-name-input" value="<?php echo $customer['organization_customer_name'];?>">
            <input type="hidden" id="current_origin" name="current_origin" value="cust_prof">
        </form>
        <div class="row">
            <div class="col-md-4">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <span class="title bold"><?php print CommonLanguage::getMessage('organization'); ?></span>
                        <hr>
                        <div id=persondata><i class='fa fa-3x fa-building'></i>
                        <?php print CommonLanguage::getMessage('Name'); ?>:
                            <span style="color:black;" id="Name" class="customer_profile_name blue-span"><?php echo $customer['organization_customer_name'];?></span>
                            <div>
                            <?php print CommonLanguage::getMessage('Phone'); ?>:
                                <span style="color:black;" class="blue-span"><?php echo $customer['orgaization_mobile_phone'];?></span>
                                <br> <?php print CommonLanguage::getMessage('address'); ?>:
                                <span style="color:black;" class="blue-span"><?php echo $customer['organization_address'];?></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body" id="persondialog">
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body" id="dealsdialog"></div>
                </div>
            </div>
            <div class="col-md-8"> 
                <span id="activitylistt2">
                    <div class=panel-default>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-md-10">
                                    <a class='btn btn-warning add btn-activity2 ' data-toggle="modal" data-target="#activity_modal" data-origin="cust_prof" id="add_activity" data-event-name='add' data-customer-id="<?php echo $customer['organization_id'];?>" data-customer-name="<?php echo $customer['organization_customer_name'];?>"> <?php print CommonLanguage::getMessage('add_activity'); ?></a>
                                    <span class="noteseditor btn btn-complete"><?php print CommonLanguage::getMessage('add_notes'); ?></span>
                                    <a class='btn bg-info-light text-white ' data-toggle="modal" data-target="#current_call_modal" ><?php print CommonLanguage::getMessage('current_call'); ?></a>
                                </div>
                                <div class="col-md-2 pull-right">
                                    <div class='checkbox check-primary'>
                                        <input  type="checkbox" name="is_potiential" id="is_potiential" <?php echo $customer['is_potiential'] == 1 ? 'checked': '';?>/>
                                        <label for ="is_potiential"><?php  echo CommonLanguage::getMessage('is_potiential');?></label>
                                    </div>
                                </div>
                            </div>
                            <div id="noteseditor" class="hidden">
                                <div class="row"> 
                                    <div class="col-md-12 m-t-10 m-b-10">
                                        <textarea id="overall_note" class="form-control"></textarea>
                                    </div>
                                </div>
                                <div class="btn-notes">
                                    <a class='btn btn-primary save'><?php print CommonLanguage::getMessage('Save'); ?></a> 
                                    <a class='btn btn-default cancel'><?php print CommonLanguage::getMessage('cancel'); ?></a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <h3 id='planevent'><?php print CommonLanguage::getMessage('planned'); ?></h3>
                    <span data-type=plan>
                        <div id="vertical-timeline" class="vertical-container light-timeline no-margins">
                        </div>
                    </span>
                    <h3 id='over'><?php print CommonLanguage::getMessage('overdue'); ?></h3>
                    <span data-type=overdue>
                        <div id="vertical-timeline" class="vertical-container light-timeline no-margins">
                        </div>
                    </span>
                </span>
                <h3><?php  echo CommonLanguage::getMessage('log');?></h3>
                <div id="logfilter" class="btn-group">
                    <a data-filter-type=All class="btn btn-default active"><?php  echo CommonLanguage::getMessage('all_log');?></a>
                    <a data-filter-type=activity class="btn btn-default"><?php  echo CommonLanguage::getMessage('activity');?></a>
                    <a data-filter-type=log class="btn btn-default "> <?php  echo CommonLanguage::getMessage('log');?></a>
                    <a data-filter-type=statelog class="btn btn-default "><?php  echo CommonLanguage::getMessage('statelog');?></a>
                    <a data-filter-type=notelog class="btn btn-default "><?php  echo CommonLanguage::getMessage('notes');?> </a>
                    <a data-filter-type=inv_ret class="btn btn-default "><?php  echo CommonLanguage::getMessage('invoices_returns');?></a>
                </div>
                <span id='past'>
                    <div id="vertical-timeline" class="identify vertical-container light-timeline no-margins">
                    </div>
                </span>
            </div>
        </div>
        <?php echo Forms::ModalLoader('customer_profile_loader'); ?>
    </div>
</div>
<script>
    var filterlogtype='All',activity_flag=0;
    $(function(){
        getdeals('organization_id',$("#org_id").val());
        getperson();
        loadlog('cust_prof', $("#org_id").val());
        loadActivities($("#org_id").val())
        $("#persondialog").on("click",".add-contact-profile",function(){
            $("#contact-modal").modal('show')
        });
        $("#dealsdialog").on("click",".add-deal-profile",function(){
            $('#deal_title').val($('.customer_profile_name').html()+" Deal")
            $("#deal-modal").modal('show')
        });
        $(".btn-notes a.cancel").click(function(e) {
            $("#noteseditor").addClass('hidden');
        });
        $(".btn-notes a.save").click(function(e) {
            if ($("#overall_note").val() != "") {
                savenote("crmAjax/addNote", $("#org_id").val(),0,0,function(){
                    loadlog('cust_prof', $("#org_id").val());
                });
                $("#noteseditor").addClass('hidden');
            }
        });
        $(".noteseditor").on("click", function() {
            $("#noteseditor").removeClass('hidden');
        });
        $("#logfilter").on("click", " a", function (event) {
            $("#logfilter a").removeClass("active");
            $(this).addClass("active");
            var currentheight = $(document).height();
            $("body").attr("style", "height:" + currentheight + "px !important");
            event.preventDefault();
            event.stopPropagation();
            switch ($(this).attr("data-filter-type")) {
                case "All":
                    filterlogtype = "All";
                    break;
                case "activity":
                    filterlogtype = "activity";
                    break;
                case "log":
                    filterlogtype = "log";
                    break;
                case "statelog":
                    filterlogtype = "statelog";
                    break;
                case "notelog":
                    filterlogtype = "notelog";
                    break;
                case "inv_ret":
                    filterlogtype = "inv_ret";
                    break;
                                                    }
            loadlog('cust_prof', $("#org_id").val());
        });
        $('#is_potiential').on('click',function(){
            var is_potiential=$(this).is(":checked") ? 1 : 0;
            $("#customer_profile_loader").removeClass('hidden');
            $.ajax({
                url: "crmAjax/updateCustomerPotiential",
                method: "GET",
                data: {organization_id:$('#org_id').val(),is_potiential:is_potiential},
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            toastr.success(jqXHR.responseJSON[0]);
                        }else{
                            toastr.error(jqXHR.responseJSON[0]);
                        }
                    }
                    $("#customer_profile_loader").addClass('hidden');
                }
            });
        });
    });
</script>
<?php include 'Views/crm/contact_modal.php';
include 'Views/crm/deal_modal.php';
include 'Views/crm/activity_modal.php';
include 'Views/crm/current_call_modal.php';