
<?php
class contactdb{
    public function sales_insert_contact($companyname1, $adminemailid1, $contid, $contnametitle, $contfirstname, $contlastname, $contjobtitle, $contaddressline, $contaddresscity, $contaddressstate, $contaddresscountry, $contaddresspincode, $contstatus, $conttag, $contleadsource, $contbackground, $contowner, $contmakeprivate, $contbirthdate, $DateandTime, $contcreatedby, $contcreatedtype){
        include 'configuration.php';
        date_default_timezone_set("Asia/Kolkata");
        $DateandTime=date("Y-m-d H:i:s");
        if($contbirthdate==""){
            $contbirthdate="0000-00-00"; 
        }
        
        $result=$pdo->prepare('call sales_insert_contact("insert", "'.$companyname1.'", "'.$adminemailid1.'", "'.$contid.'", "'.$contnametitle.'", "'.$contfirstname.'", "'.$contlastname.'", "'.$contjobtitle.'", "'.$contaddressline.'", "'.$contaddresscity.'", "'.$contaddressstate.'", "'.$contaddresscountry.'", "'.$contaddresspincode.'", "'.$contstatus.'", "'.$conttag.'", "'.$contleadsource.'", "'.$contbackground.'", "'.$contowner.'", "'.$contmakeprivate.'", "'.$contbirthdate.'", "'.$DateandTime.'", "'.$contcreatedby.'", "'.$contcreatedtype.'")');
        $result->execute();
        $pdo=null;
        return "yes";
    }
    public function sales_update_contact($companyname1, $adminemailid1, $contid, $contnametitle, $contfirstname, $contlastname, $contjobtitle, $contaddressline, $contaddresscity, $contaddressstate, $contaddresscountry, $contaddresspincode, $contstatus, $conttag, $contleadsource, $contbackground, $contowner, $contmakeprivate, $contbirthdate, $DateandTime, $contcreatedby, $contcreatedtype){
        include 'configuration.php';
        date_default_timezone_set("Asia/Kolkata");
        $DateandTime=date("Y-m-d H:i:s");
        if($contbirthdate==""){
            $contbirthdate="0000-00-00"; 
        }
        $result=$pdo->prepare('call sales_insert_contact("update", "'.$companyname1.'", "'.$adminemailid1.'", "'.$contid.'", "'.$contnametitle.'", "'.$contfirstname.'", "'.$contlastname.'", "'.$contjobtitle.'", "'.$contaddressline.'", "'.$contaddresscity.'", "'.$contaddressstate.'", "'.$contaddresscountry.'", "'.$contaddresspincode.'", "'.$contstatus.'", "'.$conttag.'", "'.$contleadsource.'", "'.$contbackground.'", "'.$contowner.'", "'.$contmakeprivate.'", "'.$contbirthdate.'", "'.$DateandTime.'", "'.$contcreatedby.'", "'.$contcreatedtype.'")');
        $result->execute();
        $pdo=null;
        if( $result ) return "yes";
    }
    public function sales_update_contact_tag_status_blob($cont_id, $colmun, $value){
        session_start();
        $adminemailid=$_SESSION['emailid'];
        $companyname=$_SESSION['companyname'];
        $companytype=$_SESSION['companytype'];
        $createtype=$_SESSION['employeetype'];
        include 'configuration.php';
        date_default_timezone_set("Asia/Kolkata");
        $DateandTime=date("Y-m-d H:i:s");
        $result=$pdo->prepare('call sales_update_contact_tag_status_blob("'.$cont_id.'", "'.$colmun.'", "'.$value.'","'.$DateandTime.'", "'.$adminemailid.'", "'.$createtype.'")');
        $result->execute();
        
        if( $result ){ $pdo=null; return "success"; }
    }
    public function sales_call_insert_update_delete($type, $id, $cont_id, $cphone, $cdescr, $cresult, $cdate, $ctime, $cdatetime, $cby, $ctype){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_call_insert_update_delete("'.$type.'", "'.$id.'", "'.$cont_id.'", "'.$cphone.'", "'.$cdescr.'", "'.$cresult.'", "'.$cdate.'", "'.$ctime.'", "'.$cdatetime.'", "'.$cby.'", "'.$ctype.'")');
        $result->execute();
        
        if( $result ){ $pdo=null; return "success"; }
    }
    public function sales_deal_insert_update_delete($type, $id, $contid, $ddealname, $damount, $dmonth, $dcommissionpercentage, $dcommissionamount, $ddescr, $dstage, $ddate, $dclosedate, $ddatetime, $dby, $dtype, $dealby){
        include 'configuration.php'; 
        $result=$pdo->prepare('call sales_deal_insert_update_delete("'.$type.'", "'.$id.'", "'.$contid.'", "'.$ddealname.'", "'.$damount.'", "'.$dmonth.'", "'.$dcommissionpercentage.'", "'.$dcommissionamount.'", "'.$ddescr.'", "'.$dstage.'", "'.$ddate.'", "'.$dclosedate.'", "'.$ddatetime.'", "'.$dby.'", "'.$dtype.'", "'.$dealby.'")');
        $result->execute();
        
        if( $result ){ $pdo=null; return "success"; }
    }
    public function sales_nextaction_insert_update_delete($type, $id, $contid, $nadescr, $nastatus, $nadate, $nadatetime, $naby, $natype, $natime, $naassign, $selectoption){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_nextaction_insert_update_delete("'.$type.'", "'.$id.'", "'.$contid.'", "'.$nadescr.'", "'.$nastatus.'", "'.$nadate.'", "'.$nadatetime.'", "'.$naby.'", "'.$natype.'", "'.$natime.'", "'.$naassign.'", "'.$selectoption.'")');
        $result->execute();
        
        if( $result ){ $pdo=null; return "success"; }
    }
    public function sales_notes_insert_update_delete($type, $id, $contid, $descr, $relates, $ndate, $ndatetime, $nby, $ntype){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_notes_insert_update_delete("'.$type.'", "'.$id.'", "'.$contid.'", "'.$descr.'", "'.$relates.'", "'.$ndate.'", "'.$ndatetime.'", "'.$nby.'", "'.$ntype.'")');
        $result->execute();
        
        if( $result ){ $pdo=null; return "success"; }
    }
    public function sales_select_nextaction_pending($contid){
        session_start();
        $adminemailid=$_SESSION['emailid'];
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_nextaction_pending("'.$contid.'","'.$adminemailid.'")');
        $result->execute();
        
        if( $result ){ $pdo=null; return $result; }
    }
    public function sales_select_nextaction_get_id($contid,$nadatetime){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_nextaction_get_id("'.$contid.'","'.$nadatetime.'")');
        $result->execute();
        return $result; 
    }
    public function sales_deal_update_stage_closedate_delete($type,$change,$ddatetime,$dby,$dtype,$id){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_deal_update_stage_closedate_delete("'.$type.'","'.$change.'","'.$ddatetime.'","'.$dby.'","'.$dtype.'","'.$id.'")');
        $result->execute();
         if( $result ){ $pdo=null; return "success"; }
    }
    public function sales_select_deal_get_id($contid,$nadatetime){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_deal_get_id("'.$contid.'","'.$nadatetime.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_call_get_id($contid,$nadatetime){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_call_get_id("'.$contid.'","'.$nadatetime.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_note_get_id($contid,$nadatetime){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_note_get_id("'.$contid.'","'.$nadatetime.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_contact_alphabet($companyname,$adminemailid){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_contact_alphabet("'.$companyname.'","'.$adminemailid.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_employee_contact_alphabet($companyname,$adminemailid){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_employee_contact_alphabet("'.$companyname.'","'.$adminemailid.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_employee_contact_org_alphabet($companyname,$adminemailid){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_employee_contact_org_alphabet("'.$companyname.'","'.$adminemailid.'")');
        $result->execute();
        return $result; 
    }
    public function sales_employee_select_all($companyname,$adminemailid,$tablename1,$type){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_employee_select_all("'.$companyname.'","'.$adminemailid.'","'.$tablename1.'","'.$type.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_organization_alphabet($companyname,$adminemailid){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_organization_alphabet("'.$companyname.'","'.$adminemailid.'")');
        $result->execute();
        return $result; 
    }
    public function sales_select_contact_organization($companyname,$adminemailid){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_select_contact_organization("'.$companyname.'","'.$adminemailid.'")');
        $result->execute();
        return $result; 
    }
    public function sales_contact_star_update($cid,$value){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_contact_star_update("'.$cid.'","'.$value.'")');
        $result->execute();
        return $result; 
    }
    public function sales_update_contact_photo($cid,$value){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_update_contact_photo("'.$cid.'","'.$value.'")');
        $result->execute();
        return $result; 
    }
    public function sales_delete_contact($contid, $createby, $createtype, $DateandTime){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_delete_contact("'.$contid.'","'.$createby.'","'.$createtype.'","'.$DateandTime.'")');
        $result->execute();
        return $result; 
    }
    public function sales_contact_close($contid, $DateandTime){
        include 'configuration.php';
        $result=$pdo->prepare('call sales_contact_close("'.$contid.'","'.$DateandTime.'")');
        $result->execute();
        return $result; 
    }
}
/*include 'configuration.php';
        $result=$pdo->prepare('call sales_insert_contact("insert", "$companyname1", "$adminemailid1", "$contid", "$contnametitle", "$contfirstname", "$contlastname", ".$contjobtitle", "$contaddressline", "$contaddresscity", "$contaddressstate", "$contaddresscountry", "$pincode", "$contstatus", "$conttag", "$contleadsource", "$contbackground", "$contowner", "$contmakeprivate", "0000-00-00", "0000-00-00 00:00:00", "$contcreatedby", "$contcreatedtype", @p)');
        $result->execute();
        print_r($result);*/
?>

<?php
if(isset($_POST['insert_contact'])){
    
    $firstname=$_POST['firstname'];
    $lastname=$_POST['lastname'];
    $cont_organization=$_POST['cont_organization'];
    $cont_title=$_POST['cont_title'];
    $cont_job_title=$_POST['cont_job_title'];
    $cont_phone_number=$_POST['cont_phone_number'];
    $cont_phone_type=$_POST['cont_phone_type'];
    $cont_email_name=$_POST['cont_email_name'];
    $cont_email_type=$_POST['cont_email_type'];
    $cont_url_name=$_POST['cont_url_name'];
    $cont_url_type=$_POST['cont_url_type'];
    $cont_address=$_POST['cont_address'];
    $cont_country=$_POST['cont_country'];
    $cont_state=$_POST['cont_state'];
    $cont_city=$_POST['cont_city'];
    $cont_pincode=$_POST['cont_pincode'];
    $cont_status=$_POST['cont_status'];
    $cont_tag=$_POST['cont_tag'];
    $cont_lead=$_POST['cont_lead'];
    $cont_background=$_POST['cont_background'];
    $cont_owner=$_POST['cont_owner'];
    $cont_make_private=$_POST['cont_make_private'];
    $cont_birthday=$_POST['cont_birthday'];
    $cont_organization1=$_POST['cont_organization1'];
    $cont_org_desc=$_POST['cont_org_desc'];
    $cont_org_phone=$_POST['cont_org_phone'];
    $cont_org_url=$_POST['cont_org_url'];
    $cont_org_address=$_POST['cont_org_address'];
    $cont_org_country=$_POST['cont_org_country'];
    $cont_org_state=$_POST['cont_org_state'];
    $cont_org_city=$_POST['cont_org_city'];
    $cont_org_pincode=$_POST['cont_org_pincode'];
}
?>
