<?php
session_start();
$adminemailid=$_SESSION['emailid'];
$companyname=$_SESSION['companyname'];
$companytype=$_SESSION['companytype'];

if(($adminemailid !="")&&($companyname!="")){
if(isset($_POST['text'])){
require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
    $text=$_POST['text'];
    $m=explode("___", $text);
    
    for($i=0;$i<(count($m)-1);$i++){
        $m1=explode("@@@",$m[$i]);
        $em=$m1[0];
        $month=$m1[1];
        $year=$m1[2];
        $value=$m1[3];
        date_default_timezone_set("Asia/Kolkata");
        $DateandTime=date("Y-m-d H:i:s");
        $objpipeline->salesinsertpipelinetargetmonth($companyname, $em, $month, $year, $value, $adminemailid, "admin", $DateandTime);
    }
}
if(isset($_POST['common'])){
        
require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
$text=$_POST['common'];
$em=$_POST['em'];
//$m=explode("___", $text);
date_default_timezone_set("Asia/Kolkata");
$DateandTime=date("Y-m-d H:i:s");
$objpipeline->salesinsertcommontarget($companyname, $em, $text, $adminemailid, "admin", $DateandTime);

    
}
?>

<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/Login.php') </script>";
}?>