<?php
session_start();
if(!isset($_SESSION['titles']) || !isset($_SESSION['positions'])|| !isset($_SESSION['usernames'])){
}

$con=mysqli_connect("localhost","primarysales","S5L7lF01EQZvQrGK","primarysales_diana");
if(isset($_POST['Submit'])) {	
$zodr = $_REQUEST['zoneorder'];
$zonee = $_REQUEST['zone'];
$chnl= $_REQUEST['channel'];
$rgn = $_REQUEST['region'];
$subrgn = $_REQUEST['subregion'];
$asm = $_REQUEST['asm'];	
$exname = $_REQUEST['exname'];
$agtype = $_REQUEST['agtype'];
$rgtp = $_REQUEST['rgtype'];
$dbname = $_REQUEST['dbname'];
$dbcd = $_REQUEST['dbnamec'];
$dbaddres = $_REQUEST['dbaddres'];
$terriname = $_REQUEST['territory'];
$dbcntact = $_REQUEST['dbcontact'];
$sts='Active';
$userr=$_SESSION['titles'];
$psitn=$_SESSION['positions'];

$result = mysqli_query($con,"insert into agentsmrd(zone_order,chanelname,zone,region,sub_region,rsm_name,executive_name,agent_name,agent_type,range_type,territory_name,user_names,dbaddres,dbcontact,agent_replc)values
('$zodr','$chnl','$zonee','$rgn','$subrgn','$asm','$exname','$dbname','$agtype','$rgtp','$terriname','$userr','$dbaddres','$dbcntact','$dbcd')");
header("Location: prdashbs.php");

$msgs=$msgs."<p style='font-family:calibri;font-size:12;'>Sales web program-Auto generated email: New agent creation</p>";
$msgs=$msgs."<table style='font-family:calibri;font-size:12;width:70%%;'><th style='background:silver;' colspan='2'>New Distibutor creation</th>";
$msgs=$msgs."<tr style='background:silver'><td style='border:1px solid silver;width:50%%;' >Agent name</td><td style='border:1px solid silver;width:50%%;' >".$_REQUEST['dbname']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Address</td><td style='border:1px solid silver;' >".$_REQUEST['dbaddres']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Contact</td><td style='border:1px solid silver;' >".$_REQUEST['dbcontact']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Zone order</td><td style='border:1px solid silver;' >".$_REQUEST['zoneorder']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Zone</td><td style='border:1px solid silver;' >".$_REQUEST['zone']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Channel</td><td style='border:1px solid silver;' >".$_REQUEST['channel']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Region</td><td style='border:1px solid silver;' >".$_REQUEST['region']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Sub region</td><td style='border:1px solid silver;' >".$_REQUEST['subregion']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >RSM</td><td style='border:1px solid silver;' >".$_REQUEST['asm']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Agent type</td><td style='border:1px solid silver;' >".$_REQUEST['agtype']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Range type</td><td style='border:1px solid silver;' >".$_REQUEST['rgtype']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Territory name</td><td style='border:1px solid silver;' >".$_REQUEST['territory']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' >Agent name</td><td style='border:1px solid silver;' >".$_REQUEST['dbnamec']."</td></tr>";
$msgs=$msgs."<tr style='border:1px solid silver;'><td style='border:1px solid silver;' colspan='2'>".$psitn." - ".$userr."</td></tr>";
$msgs=$msgs."</table>";
$msgs=$msgs."<p style='font-family:calibri;font-size:12;'>Contact Sales and marketing department regarding any issues regarding this new agency information shown above.</p>";

$hdrs = "Content-type: text/html\r\n";
$hdrs .= 'To:pathmasiri@diana.lk' . "\r\n";
$hdrs .= 'From: Sales web program' . "\r\n";
mail("prasanna@diana.lk","Sale web program: New agent creation",$msgs,$hdrs);
}
?>

