if ((isset($_COOKIE["user"])) or (isset($_COOKIE["bengali"])) or (isset($_COOKIE["malayalam"])) )
{
@ob_start();
@session_start();
include '../include/connect.php';
include '../include/Form.php';
include '../include/display.php';
include '../include/common.php';
display_top();
display_cms_menu();
$SubstitutionArray['kan_']=array();
$SubstitutionArray['ben_']=array("[tr]"=>"Œ", "[tt]"=>"Š", "[~jj]"=>"…²", "[nD]"=>"—", "[pt]"=>"›", "[ddh]"=>"Ž", "[ndh]"=>"™", "[Thy]"=>"œ", "[~jc]"=>"ƒ");
$SubstitutionArray['mar_']=array("[Dya]"=>"Ž");
$SubstitutionArray['hin_']=array("[kk]"=>"‚ü", "[~gG]"=>"†¡û", "[~g~g]"=>"ˆû", "[cc]"=>"Š", "[~gm]"=>"‰", "[~gk]"=>"ƒ¡û", "[~gK]"=>"„¡û", "[~gg]"=>"…¡û", "[Ty]"=>"š", "[ThTh]"=>"›û", "[Thy]"=>"œ", "[DG]"=>"†û", "[Dk]"=>"ƒû", "[DK]"=>"„û", "[Dg]"=>"…û", "[DD]"=>"Œû", "[Dy]"=>"Ž", "[Dhy]"=>"ž");
$SubstitutionArray['tam_']=array("[j]"=>"ˆ", "[ja]"=>"ƒ", "[~ju]"=>"š", "[~jU]"=>"œ", "[Sh]"=>"‰", "[Sha]"=>"„", "[S]"=>"Š", "[Sa]"=>"…", "[h]"=>"‹", "[ha]"=>"†", "[kSh]"=>"Œ", "[kSha]"=>"‡");
$SubstitutionArray['tel_']=array();
$SubstitutionArray['mal_']=array();
//!This is the different class representation for different languages.
/*!
for more details about $lang_arr, click here.
*/
$cls = $lang_arr[$_SESSION['ltag']];
//print_r($_POST);
?>
print"
";
print"
Add / Edit pack_plant
";
//!The Current Record Date.
$rec_date=date("Y-m-d H:i:s");
//!The Tab Id field with a suffix of the language tag.
/*!E.g kan_ for Kannada, hin_ for Hindi etc.*/
$nid = $_SESSION['ltag']."tab_id";
//!The Package Id field with a suffix of the language tag.
/*!E.g kan_ for Kannada, hin_ for Hindi etc.*/
$pkid = $_SESSION['ltag']."pack_id";
//!The Simple tab Id field, irrespective of language.
$tab = "tab_id";
if($_POST['submit']=='Add')
{
//refresh_ids('tab_id', $_SESSION['ltag'].'pack_plant');
$nid=get_next_id('tab_id', $_SESSION['ltag'].'pack_plant');
if($_SESSION['ltag']=="")
$nid=generate_valid_id($nid,6);
elseif($_SESSION['ltag']=='kan_')
{
if($nid<900000) $nid=900000+$nid;
else $nid=generate_valid_id($nid,6);
}
elseif($_SESSION['ltag']=="hin_")
{
if($nid<200000) $nid=200000+$nid;
else $nid=generate_valid_id($nid,6);
}
elseif($_SESSION['ltag']=="mal_")
{
if($nid<300000) $nid=300000+$nid;
else $nid=generate_valid_id($nid,6);
}
elseif($_SESSION['ltag']=="mar_")
{
if($nid<500000) $nid=500000+$nid;
else $nid=generate_valid_id($nid,6);
}
elseif($_SESSION['ltag']=="tam_")
{
if($nid<400000) $nid=400000+$nid;
else $nid=generate_valid_id($nid,6);
}
elseif($_SESSION['ltag']=="ben_")
{
if($nid<600000) $nid=600000+$nid;
else $nid=generate_valid_id($nid,6);
}
elseif($_SESSION['ltag']=="tel_")
{
if($nid<700000) $nid=700000+$nid;
else $nid=generate_valid_id($nid,6);
}
// $nid = generate_valid_id(get_next_id($nid),6);
if($_SESSION['ltag'])
{
$SubPlantPart=addslashes($_POST['plant_part']);
$SubMedUse=addslashes($_POST['med_use']);
foreach($SubstitutionArray[$_SESSION['ltag']] as $subkey=>$subval)
{
$SubPlantPart=str_replace($subval, $subkey, $SubPlantPart);
$SubMedUse=str_replace($subval, $subkey, $SubMedUse);
}
$insqry = "INSERT INTO ".$_SESSION['ltag']."pack_plant (tab_id, pack_id, plant_id,plant_part,med_use) VALUES('$nid','".$_POST[$pkid]."' , '".$_POST['plant_id']."' ,'".utf8_decode($SubPlantPart)."', '".utf8_decode($SubMedUse)."')";
}
else
{
$insqry = "INSERT INTO ".$_SESSION['ltag']."pack_plant (tab_id, pack_id, plant_id,plant_part,med_use) VALUES('$nid','".$_POST[$pkid]."' , '".$_POST['plant_id']."' ,'".addslashes($_POST['plant_part'])."', '".addslashes($_POST['med_use'])."')";
}
$_SESSION['PackId']=$_POST[$pkid];
}
if($_POST['submit']=='Update')
{
if($_SESSION['ltag'])
{
$SubPlantPart=addslashes($_POST['plant_part']);
$SubMedUse=addslashes($_POST['med_use']);
foreach($SubstitutionArray[$_SESSION['ltag']] as $subkey=>$subval)
{
$SubPlantPart=str_replace($subval, $subkey, $SubPlantPart);
$SubMedUse=str_replace($subval, $subkey, $SubMedUse);
}
$insqry = "UPDATE ".$_SESSION['ltag']."pack_plant SET plant_id='".addslashes($_POST['plant_id'])."', plant_part='".utf8_decode($SubPlantPart)."', med_use='".utf8_decode($SubMedUse)."' WHERE $tab='".$_POST['id']."'";
}
else
{
$insqry = "UPDATE ".$_SESSION['ltag']."pack_plant SET plant_id='".addslashes($_POST['plant_id'])."', plant_part='".addslashes($_POST['plant_part'])."', med_use='".addslashes($_POST['med_use'])."' WHERE $tab='".$_POST['id']."'";
}
}
if($insqry!='')
{
PRINT $insqry;
$result = mysql_query($insqry)or die(mysql_error());
// print_r($_SESSION);
header('location:show_pack_plant.php?packid='.$_SESSION['PackId']);
}
//!Initialization of Form Prototype.
/*!
for more details about Html_form method, click here.
*/
$curform=new Html_form('Addedit_'.'pack_plant'.'.php','post','form1','','','chk_all','');
$curform->start();
if($_GET['id']!="")
{
$result=mysql_query("SELECT * FROM ".$_SESSION['ltag']."pack_plant where tab_id='".$_GET['id']."'");
$row=mysql_fetch_array($result);
$curform->displayhidden("id",$_GET['id']);
}
//PACKAGES DROP DOWN
//!The list of Package Names in the form of an array.
/*!
for more details about get_list_data function, click here.
*/
$packs=get_list_data("'".$_SESSION['ltag']."package' ",$pkid,array('pack_name'),'',"SELECT * FROM ".$_SESSION['ltag']."package ORDER BY pack_name");
if($_SESSION['ltag'])
{
foreach($packs as $key=>$Val)
{
$packs[$key]=utf8_encode($Val);
}
}
//!Passing on the Package Id to another Program.
$_SESSION['PackId']=$row['pack_id'];
$curform->displayselectrow($_SESSION['ltag']."pack_id",'Package',$packs,$row['pack_id'],'','','--- SELECT ---','','',$cls);
//PLANTS DROP DOWN
//!The list of Plants in the form of an array.
/*!
for more details about get_list_data function, click here.
*/
$plants=get_list_data("'".$_SESSION['ltag']."botmast'",'plant_id',array('genus','species'),'',"SELECT * FROM ".$_SESSION['ltag']."botmast ORDER BY genus");
if($_SESSION['ltag'])
{
foreach($plants as $key=>$Val)
{
$plants[$key]=utf8_encode($Val);
}
}
$curform->displayselectrow('plant_id','Plant',$plants,$row['plant_id'],'','','--- SELECT ---','','',$cls);
if($_SESSION['ltag'])
{
$curform->displaytextrow('plant_part','Part used',utf8_encode($row['plant_part']),35,100,1,'','',$cls);
$curform->displaytextarearow('med_use','Medicinal use',utf8_encode($row['med_use']),35,3,'','1',$cls);
}
else
{
$curform->displaytextrow('plant_part','Part used',$row['plant_part'],35,100,1,'','',$cls);
$curform->displaytextarearow('med_use','Medicinal use',$row['med_use'],35,3,'','1',$cls);
}
if($_GET['id']=="")
{
$curform->displayhidden("submit","Add");
$curform->displaysubmitrow("submit1","Add");
}
else
{
$curform->displayhidden("submit","Update");
$curform->displaysubmitrow("submit1","Update");
}
$curform->end();
print"
";
}
else
{
echo "You are not Authorised to view this page ! ! !";
}
?>