";
$country_list_html = "";
while($selected_country_details = $sth->fetchrow_hashref)
{
my $cid = $selected_country_details->{'country_id'};
if($cid eq $_[0]) {
$country_list_html .= "$selected_country_details->{'country_name'} ";
} else {
$country_list_html .= "$selected_country_details->{'country_name'} ";
}
}
$sth->finish;
$country_list_html .= " ";
return $country_list_html;
}
################################################
# get all the state list in select drop down #
################################################
sub get_state_list
{
my($st, $sth, $state_details);
$st = "select * from state";
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st);
}
$state_list_html = "
State*
-- Select state -- ";
while($state_details = $sth->fetchrow_hashref)
{
my $cid = $state_details->{'state_id'};
$state_list_html .= "$state_details->{'state_name'} ";
}
$sth->finish;
$state_list_html .= " ";
return $state_list_html;
}
#########################################################
# Get javascript code to show state for India #
#########################################################
sub get_state_js {
my ($state_html, %state_val, $state_id, $form_name);
$form_name = $_[0];
%state_val = &get_indian_state();
$state_html = "";
return $state_html;
}
#################################################
# get all the state list #
#################################################
sub get_indian_state
{
my($st, $sth, %state_val);
$st = "select * from state order by state_name";
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st);
}
while($state_details = $sth->fetchrow_hashref)
{
my $sid = $state_details->{'state_id'};
my $sname = $state_details->{'state_name'};
$state_val{$sid} = $sname;
}
$sth->finish;
return %state_val;
}
################################################
# get all the price basis list in select drop down #
################################################
sub get_price_basis_list
{
my($st, $sth, $price_basis_details);
$st = "select * from price_basis_options";
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st);
}
$price_basis_html = "
-- Select Price Basis -- ";
while($price_basis_details = $sth->fetchrow_hashref)
{
my $pbid = $price_basis_details->{'price_basis_id'};
$price_basis_html .= "$price_basis_details->{'price_basis_name'} ";
}
$sth->finish;
$price_basis_html .= " ";
return $price_basis_html;
}
#-#############################################
# Sub: Get Region
sub get_region {
my($st, $sth, $region_id);
if($_[0] ne "IN") {
$st = "select region_id from country where country_id = '$_[0]'";
}
elsif($_[0] eq "IN" && $_[1] ne "") {
$st = "select region_id from state where state_id = '$_[1]'";
}
$sth = $dbh->prepare($st);
if(!$sth) {
dataerror($dbh->errstr);
}
if(!($sth->execute)) {
dataerror($dbh->errstr);
}
$region_id = $sth->fetchrow_array;
$sth->finish;
return $region_id;
}
#######################################################
#### Delete record from temp enquiry_record table ####
#######################################################
sub delete_temp_rfq {
my($st, $sth);
$st = $_[0];
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
$sth->finish;
}
#################################
#- Get Current Year #
#################################
sub get_current_year {
my $year_val = (gmtime)[5] + 1900;
my $year_html = "";
for($z=0;$z<2;$z++) {
if($_[0] == $year_val) {
$year_html .= "$year_val ";
} else {
$year_html .= "$year_val ";
}
$year_val += 1;
}
$year_html .= " ";
return $year_html
}
#########################
#- Get Current Month #
#########################
sub get_current_month_html {
my ($mon, $mon_html);
if($_[0] ne "") {
$mon = $_[0];
}
else {
$mon = (gmtime)[4] + 1;
}
$mon_html = "";
foreach $monval (sort {$a <=> $b} keys %mon_val) {
if($monval == $mon) {
$mon_html .= "$mon_val{$monval} \n";
}
else {
$mon_html .= "$mon_val{$monval} \n";
}
}
$mon_html .= " ";
return $mon_html
}
################################################################
# preview for the inquiry existance & show accordingly #
################################################################
sub preview_temp_enq {
my ($temp_enq_details, @temp_grade_product_array, $temp_rfq_preview_html,
@return_preview_temp_enq);
$temp_enq_details = &get_details("select * from temp_enquiry_record where (temp_enq_no='$_[0]' and temp_process_status='on')",__FILE__,__LINE__);
if($temp_enq_details ne "") {
@temp_grade_product_array = &get_id_array("select temp_grade_product_no from temp_enquiry_record_to_grade where temp_enq_no = '$_[0]' order by temp_grade_product_no",__FILE__,__LINE__);
if($#temp_grade_product_array != -1)
{
my $i = 0;
foreach $temp_grade_product_array (sort {$a <=> $b} @temp_grade_product_array)
{
###$temp_rfq_preview_html .= &get_temp_rfq_record_html($temp_grade_product_array,$temp_enq_details->{'temp_grade_option'},$_[0],$temp_enq_details->{'temp_unit_type'},$_[1],$i,$temp_enq_details->{'temp_grade_country'});
$temp_rfq_preview_html .= &get_temp_rfqpreview_html($temp_grade_product_array,$temp_enq_details->{'temp_grade_option'},$_[0],$temp_enq_details->{'temp_unit_type'},$_[1],$i,$temp_enq_details->{'temp_grade_country'});
$i++;
}
}
}
@return_preview_temp_enq =($temp_enq_details,$#temp_grade_product_array,$temp_rfq_preview_html);
#print " $temp_rfq_preview_html ";
return @return_preview_temp_enq;
}
sub purchas_order_html{
my ($temp_enq_details, @temp_grade_product_array, $temp_rfq_preview_html,@return_preview_temp_enq);
$temp_enq_details = &get_details("select * from temp_enquiry_record where (temp_enq_no='$_[0]' and temp_process_status='on')",__FILE__,__LINE__);
if($temp_enq_details ne "") {
@temp_grade_product_array = &get_id_array("select temp_grade_product_no from temp_enquiry_record_to_grade where temp_enq_no = '$_[0]' order by temp_grade_product_no",__FILE__,__LINE__);
if($#temp_grade_product_array != -1)
{
my $i = 0;
foreach $temp_grade_product_array (sort {$a <=> $b} @temp_grade_product_array)
{
###$temp_rfq_preview_html .= &get_temp_rfq_record_html($temp_grade_product_array,$temp_enq_details->{'temp_grade_option'},$_[0],$temp_enq_details->{'temp_unit_type'},$_[1],$i,$temp_enq_details->{'temp_grade_country'});
$temp_rfq_preview_html .= &get_temp_rfqpreview_html($temp_grade_product_array,$temp_enq_details->{'temp_grade_option'},$_[0],$temp_enq_details->{'temp_unit_type'},$_[1],$i,$temp_enq_details->{'temp_grade_country'});
$i++;
}
}
}
@return_preview_temp_enq =($temp_enq_details,$#temp_grade_product_array,$temp_rfq_preview_html);
#print " $temp_rfq_preview_html ";
return @return_preview_temp_enq;
}
#-#############################################
# Sub: Get single value
#-#############################################
sub get_single_value {
my($st, $sth, $single_val);
$st = $_[0];
$sth = $dbh->prepare($st);
if(!$sth) {
dataerror($dbh->errstr,$_[1],$_[2]);
}
if(!($sth->execute)) {
dataerror($dbh->errstr,$_[1],$_[2]);
}
$single_val = $sth->fetchrow_array;
$sth->finish;
return $single_val;
}
#-#############################################
# Sub: Get Details based on single value
#-#############################################
sub get_details{
my($st, $sth, $details_val);
$st = $_[0];
$sth = $dbh->prepare($st);
if(!$sth) {
dataerror($dbh->errstr,$_[1],$_[2]);
}
if(!($sth->execute)) {
#print "$dbh->errstr $_[0],$_[1] $_[2]";
dataerror($dbh->errstr,$_[1],$_[2]);
}
$details_val = $sth->fetchrow_hashref;
$sth->finish;
return $details_val;
}
#############################################################
# View for the inquiry existance & show accordingly #
#############################################################
sub view_enq {
my ($enq_details, @grade_product_array, $rfq_preview_html, @return_preview_enq);
$enq_details = &get_details("select * from enquiry_record where enq_no = '$_[0]'");
if($enq_details ne "") {
@grade_product_array = &get_id_array("select grade_product_no from enquiry_record_to_grade where enq_no = '$_[0]'",__FILE__,__LINE__);
if($#grade_product_array != -1)
{
foreach $grade_product_array (@grade_product_array)
{
my $st = "select * from grade_product_enquiry where grade_product_no = '$grade_product_array'";
$rfq_view_html .= &get_rfq_record_html($st,$enq_details->{'grade_option'},$_[0],$enq_details->{'unit_type'},$_[1],$enq_details->{'grade_country'});
}
}
}
@return_view_enq = ($enq_details,$#grade_product_array,$rfq_view_html);
return @return_view_enq;
}
#-#######################################################
#- Get all grade_product_no for a enq_no #
#-#######################################################
sub get_rfq_record_html
{
my($grade_product_details, $g_name, $p_name, $s_f_name, $price_val, $price_html, $cols,$gp_rfq_details);
my($e_c_name, $rfq_record_html, $dim_unit, $wt_unit,$currency_type, $amt_val, $amt_value, $amt_html);
$grade_product_details = &get_details($_[0],__FILE__,__LINE__);
my $st_sum_qty="SELECT sum(quantity) as qty FROM `grade_product_offer` WHERE grade_product_no =$grade_product_details->{'grade_product_no'}";
$qty = &get_details($st_sum_qty,__FILE__,__LINE__);
my $sum_qty=$qty->{'qty'};
#print "$sum_qty " ;
$gp_rfq_details = &get_details("select * from grade_product_enquiry where grade_product_no = '$grade_product_details->{'grade_product_no'}'",__FILE__,__LINE__);
$p_name = &get_single_value("select product_name from products where product_id='$grade_product_details->{'product_id'}'",__FILE__,__LINE__);
$s_f_name = &get_single_value("select surface_finish_name from surface_finish where surface_finish_id='$grade_product_details->{'surface_finish_id'}'",__FILE__,__LINE__);
$e_c_name = &get_single_value("select edge_cond_name from edge_condition where edge_cond_id='$grade_product_details->{'edge_cond_id'}'",__FILE__,__LINE__);
if($_[3] eq "metric") {
$dim_unit = "mm";
$wt_unit = "MT"
}
elsif($_[3] eq "fps") {
$dim_unit = "Inch";
$wt_unit = "Lbs"
}
if ((($_[8] ne "IN") && ($_[9] == 0))) {
$currency_type = "USD";
} else {
$currency_type = "Rs";
}
if($_[4] eq "view_offer_details" || $_[4] eq "send_purchase_order" || $_[4] eq "view_po" || $_[4] eq "view_oa" || $_[4] eq "view_invoice")
{
$price_val = "$grade_product_details->{'price_mt'} ";
$price_html = "Price ($currency_type/$wt_unit) ";
$cols = 13;
if($_[4] eq "view_invoice") {
$amt_value = $grade_product_details->{'quantity'} * $grade_product_details->{'price_mt'};
$amt_val = "$amt_value ";
$amt_html = "Amount ($currency_type) ";
$cols = 14;
}
}
else {
$cols = 12;
}
if($grade_product_details->{'grade_id'} != 0) {
$g_name = &get_single_value("select $_[5] from grades where grade_id='$grade_product_details->{'grade_id'}'",__FILE__,__LINE__);
} else {
$g_name = "-";
}
###- This is due to show value highlighted which are chaged from offer to RFQ
###- ===========================================================
my (%key_hash_physical, @key_arr_physical, $key_arr_phy, $physical_html, @keys_of_hash_physical);
@keys_of_hash_physical = ('grade_id','product_id','surface_finish_id','edge_cond_id');
%key_hash_physical = (
'grade_id' => $g_name,
'product_id' => $p_name,
'surface_finish_id' => $s_f_name,
'edge_cond_id' => $e_c_name
);
@key_arr_physical = (thickness_nom,thickness_tol,width_nom,width_tol,length_nom,length_tol,coil_weight,quantity);
foreach $key_hash_phy (@keys_of_hash_physical) {
if($_[4] eq "view_offer_details" && ($grade_product_details->{$key_hash_phy} != $gp_rfq_details->{$key_hash_phy}) ) {
$physical_html .= "$key_hash_physical{$key_hash_phy} ";
}
else {
$physical_html .= "$key_hash_physical{$key_hash_phy} ";
}
}
foreach $key_arr_phy (@key_arr_physical) {
if($key_arr_phy eq 'quantity'){
if($sum_qty > $gp_rfq_details->{'quantity'}){
$qty_msg=' ** Total Quantity of current offer and other offers for current RFQ is getting exceeded. ';
}
}
if($_[4] eq "view_offer_details" && ($grade_product_details->{$key_arr_phy} ne $gp_rfq_details->{$key_arr_phy}) ) {
$physical_html .= "$grade_product_details->{$key_arr_phy} ";
}
else {
$physical_html .= "$grade_product_details->{$key_arr_phy} ";
}
}
if($_[1] eq "no") {
$rfq_record_html = " $physical_html $price_val \n $amt_val ";
}
elsif($_[1] eq "yes")
{
my (@key_arr_chemical, @key_arr_mechnical, $chemical_html, $key_arr_chem, $key_arr_mech, $mechnical_html);
@key_arr_chemical = (C_amt,Mn_amt,P_amt,S_amt,Si_amt,Cr_min_amt,Cr_amt,Ni_min_amt,Ni_amt,Mo_min_amt,Mo_amt,N_amt,Cu_other_amt);
@key_arr_mechnical = (tensile_strength,yield_strength,elongation,hardness_bhn,hardness_rb);
foreach $key_arr_chem (@key_arr_chemical) {
if($_[4] eq "view_offer_details" && ($grade_product_details->{$key_arr_chem} ne $gp_rfq_details->{$key_arr_chem}) ) {
$chemical_html .= "$grade_product_details->{$key_arr_chem} ";
}
else {
$chemical_html .= "$grade_product_details->{$key_arr_chem} ";
}
}
foreach $key_arr_mech (@key_arr_mechnical) {
if($_[4] eq "view_offer_details" && ($grade_product_details->{$key_arr_mech} ne $gp_rfq_details->{$key_arr_mech}) ) {
$mechnical_html .= "$grade_product_details->{$key_arr_mech} ";
}
else {
$mechnical_html .= "$grade_product_details->{$key_arr_mech} ";
}
}
$rfq_record_html = qq~
Chemical Composition (In %)
C (Max)
Mn (Max)
P (Max)
S (Max)
Si (Max)
Cr
Ni
Mo
Nitrogen (Max)
Cu/Other
(Min)
(Max)
(Min)
(Max)
(Min)
(Max)
~;
$rfq_record_html .= " $chemical_html
";
$rfq_record_html .= qq~
Mechanical Composition
Tensile StrengthMpa(Min)
Yield Strength
% Age Elongation in 50 mm gauge length min
Hardness
(BHN)
(Rb)
~;
$rfq_record_html .= " $mechnical_html
";
$rfq_record_html .= qq~
Physical Composition
Grade
Product
Surface Finish
Edge Condition
Thickness ($dim_unit)
Width ($dim_unit)
Length ($dim_unit)
Coil/Pallet Weight ($wt_unit)
Quantity ($wt_unit)
$price_html
$amt_html
Nom.
Tol.
Nom.
Tol.
Nom.
Tol.
~;
$rfq_record_html .= " $physical_html $price_val \n $amt_val
";
}
return $rfq_record_html;
}
#-#######################################################
#- Get all grade_product_no for a enq_no #
#-#######################################################
sub get_rfq_record_html1
{
$count=$_[10];
my($grade_product_details, $g_name, $p_name, $s_f_name, $price_val, $price_html, $cols,$gp_rfq_details);
my($e_c_name, $rfq_record_html, $dim_unit, $wt_unit,$currency_type, $amt_val, $amt_value, $amt_html);
$grade_product_details = &get_details($_[0],__FILE__,__LINE__);
if($_[4] eq "view_po")
{
my $stf ="SELECT * FROM `grade_product_offer` WHERE grade_product_offer_no = \"$grade_product_details->{'fk_grade_product_no'}\" ";
$gp_offer = &get_details($stf,__FILE__,__LINE__);
$gp_rfq_details = &get_details("select * from grade_product_po where grade_product_no = '$grade_product_details->{'grade_product_no'}'",__FILE__,__LINE__);
$p_name = &get_single_value("select product_name from products where product_id='$grade_product_details->{'product_id'}'",__FILE__,__LINE__);
$s_f_name = &get_single_value("select surface_finish_name from surface_finish where surface_finish_id='$grade_product_details->{'surface_finish_id'}'",__FILE__,__LINE__);
$e_c_name = &get_single_value("select edge_cond_name from edge_condition where edge_cond_id='$grade_product_details->{'edge_cond_id'}'",__FILE__,__LINE__);
}else{
$gp_rfq_details = &get_details("select * from grade_product_enquiry where grade_product_no = '$grade_product_details->{'grade_product_no'}'",__FILE__,__LINE__);
$p_name = &get_single_value("select product_name from products where product_id='$grade_product_details->{'product_id'}'",__FILE__,__LINE__);
$s_f_name = &get_single_value("select surface_finish_name from surface_finish where surface_finish_id='$grade_product_details->{'surface_finish_id'}'",__FILE__,__LINE__);
$e_c_name = &get_single_value("select edge_cond_name from edge_condition where edge_cond_id='$grade_product_details->{'edge_cond_id'}'",__FILE__,__LINE__);
#$grade_product_details = &get_details($_[0],__FILE__,__LINE__);
$p_html = &get_selected_product_html($grade_product_details->{'product_id'},$count);
$sf_html = &get_selected_sf_html($grade_product_details->{'product_id'},$grade_product_details->{'surface_finish_id'},$count);
$ec_html = &get_selected_ec_html($grade_product_details->{'product_id'},$grade_product_details->{'edge_cond_id'},$count);
}
if($_[3] eq "metric") {
$dim_unit = "mm";
$wt_unit = "MT"
}
elsif($_[3] eq "fps") {
$dim_unit = "Inch";
$wt_unit = "Lbs"
}
if ((($_[8] ne "IN") && ($_[9] == 0))) {
$currency_type = "USD";
} else {
$currency_type = "Rs";
}
if($_[4] eq "view_offer_details" || $_[4] eq "send_purchase_order" || $_[4] eq "view_invoice")
{
$price_val = " {'price_mt'}\"> ";
$price_html = "Price ($currency_type/$wt_unit) ";
$cols = 13;
if($_[4] eq "view_invoice") {
$amt_value = $grade_product_details->{'quantity'} * $grade_product_details->{'price_mt'};
$amt_val = " $amt_value ";
$amt_html = "Amount ($currency_type) ";
$cols = 14;
}
if($_[4] eq "send_purchase_order"){
$price_val .= qq~ ~;
}
}
elsif($_[4] eq "view_po")
{
if($grade_product_details->{'price_mt'} ne $gp_offer->{'price_mt'}) {
$price_val = "$grade_product_details->{'price_mt'} ";
}
else{
$price_val = "$grade_product_details->{'price_mt'} ";
}
$price_html = "Price ($currency_type/$wt_unit) ";
$cols = 13;
if($_[4] eq "view_invoice") {
$amt_value = $grade_product_details->{'quantity'} * $grade_product_details->{'price_mt'};
$amt_val = " $amt_value ";
$amt_html = "Amount ($currency_type) ";
$cols = 14;
}
}
else {
$cols = 12;
}
if($grade_product_details->{'grade_id'} != 0) {
$g_name = &get_single_value("select $_[5] from grades where grade_id='$grade_product_details->{'grade_id'}'",__FILE__,__LINE__);
} else {
$g_name = "-";
}
###- This is due to show value highlighted which are chaged from offer to RFQ
###- ===========================================================
my (%key_hash_physical, @key_arr_physical, $key_arr_phy, $physical_html, @keys_of_hash_physical);
@keys_of_hash_physical = ('grade_id','product_id','surface_finish_id','edge_cond_id');
%key_hash_physical = (
'grade_id' => $g_name,
'product_id' => $p_name,
'surface_finish_id' =>$s_f_name,
'edge_cond_id' => $e_c_name
);
$grade_html1 = &get_grade_html1($grade_product_details->{'grade_id'},$count);
@key_arr_physical = (thickness_nom,thickness_tol,width_nom,width_tol,length_nom,length_tol,coil_weight,quantity);
if($_[4] eq 'view_po' ) {
foreach $key_hash_phy (@keys_of_hash_physical) {
if($grade_product_details->{$key_hash_phy} ne $gp_offer->{$key_hash_phy})
{$physical_html .= " $key_hash_physical{$key_hash_phy} ";
}
else{
$physical_html .= " $key_hash_physical{$key_hash_phy} ";
}
}
}
else {
$physical_html .= qq~ $grade_html1 ~;
$physical_html .= qq~ $p_html
$sf_html
$ec_html ~;
#$physical_html .= " $get_selected_product_html ";
#$physical_html .= qq~ -$s_f_name- ~;
#$physical_html .= " ";
}
foreach $key_arr_phy (@key_arr_physical) {
if($_[4] eq "view_po" ) {
if($grade_product_details->{$key_arr_phy} ne $gp_offer->{$key_arr_phy}) {
$physical_html .= " $grade_product_details->{$key_arr_phy} ";
}else{
$physical_html .= "$grade_product_details->{$key_arr_phy} ";
}
}
else {
my $kname= $key_arr_phy.$count;
if($key_arr_phy eq 'length_tol' || $key_arr_phy eq 'length_nom'){
$physical_html .= " {$key_arr_phy}\" OnFocus=get_dim_val() > ";
}
else{
$physical_html .= " {$key_arr_phy}\" > ";
}
}
}
if($_[1] eq "no") {
$rfq_record_html = " $physical_html $price_val \n $amt_val ";
}
elsif($_[1] eq "yes")
{
my (@key_arr_chemical, @key_arr_mechnical, $chemical_html, $key_arr_chem, $key_arr_mech, $mechnical_html);
@key_arr_chemical = (C_amt,Mn_amt,P_amt,S_amt,Si_amt,Cr_min_amt,Cr_amt,Ni_min_amt,Ni_amt,Mo_min_amt,Mo_amt,N_amt,Cu_other_amt);
@key_arr_mechnical = (tensile_strength,yield_strength,elongation,hardness_bhn,hardness_rb);
foreach $key_arr_chem (@key_arr_chemical) {
if($_[4] eq 'view_po' ) {
if($grade_product_details->{$key_arr_chem} ne $gp_offer->{$key_arr_chem}) {
$chemical_html .= " $grade_product_details->{$key_arr_chem} ";
}
else{
$chemical_html .= "$grade_product_details->{$key_arr_chem} ";
}
}
elsif($_[4] eq "view_offer_details" && ($grade_product_details->{$key_arr_chem} ne $gp_rfq_details->{$key_arr_chem}) ) {
$chemical_html .= "$grade_product_details->{$key_arr_chem} ";
}
else {
my $kname= $key_arr_chem.$count;
$chemical_html .= " {$key_arr_chem}\" > ";
}
}
foreach $key_arr_mech (@key_arr_mechnical) {
if($_[4] eq 'view_po' ) {
if($grade_product_details->{$key_arr_mech} ne $gp_offer->{$key_arr_mech} ) {
$mechnical_html .= " $grade_product_details->{$key_arr_mech} ";
}
else{
$mechnical_html .= "$grade_product_details->{$key_arr_mech} ";
}
}
elsif($_[4] eq "view_offer_details" && ($grade_product_details->{$key_arr_mech} ne $gp_rfq_details->{$key_arr_mech}) ) {
$mechnical_html .= "$grade_product_details->{$key_arr_mech} ";
}
else {
my $kname= $key_arr_mech.$count;
$mechnical_html .= " {$key_arr_mech}\"> ";
}
}
$rfq_record_html = qq~
Chemical Composition (In %)
C (Max)
Mn (Max)
P (Max)
S (Max)
Si (Max)
Cr
Ni
Mo
Nitrogen (Max)
Cu/Other
(Min)
(Max)
(Min)
(Max)
(Min)
(Max)
~;
$rfq_record_html .= " $chemical_html
";
$rfq_record_html .= qq~
Mechanical Composition
Tensile StrengthMpa(Min)
Yield Strength Mpa(Min)
% Age Elongation in 50 mm gauge length min
Hardness
(BHN)
(Rb)
~;
$rfq_record_html .= "$mechnical_html
";
$rfq_record_html .= qq~
Physical Composition
Check to include in Purchase Order
Grade
Product
Surface Finish
Edge Condition
Thickness ($dim_unit)
Width ($dim_unit)
Length ($dim_unit)
Coil/Pallet Weight ($wt_unit)
Quantity ($wt_unit)
$price_html
$amt_html
Nom.
Tol.
Nom.
Tol.
Nom.
Tol.
~;
$rfq_record_html .= " $physical_html $price_val \n $amt_val ";
}
return $rfq_record_html;
}
sub get_rfq_record_html_oa
{
my($grade_product_details, $g_name, $p_name, $s_f_name, $price_val, $price_html, $cols,$gp_rfq_details);
my($e_c_name, $rfq_record_html, $dim_unit, $wt_unit,$currency_type, $amt_val, $amt_value, $amt_html);
$grade_product_details = &get_details($_[0],__FILE__,__LINE__);
$gp_rfq_details = &get_details("select * from grade_product_enquiry where grade_product_no = '$grade_product_details->{'grade_product_no'}'",__FILE__,__LINE__);
$p_name = &get_single_value("select product_name from products where product_id='$grade_product_details->{'product_id'}'",__FILE__,__LINE__);
$s_f_name = &get_single_value("select surface_finish_name from surface_finish where surface_finish_id='$grade_product_details->{'surface_finish_id'}'",__FILE__,__LINE__);
$e_c_name = &get_single_value("select edge_cond_name from edge_condition where edge_cond_id='$grade_product_details->{'edge_cond_id'}'",__FILE__,__LINE__);
my $stp ="SELECT * FROM `grade_product_po` WHERE grade_product_po_no = \"$grade_product_details->{'fk_grade_product_po_no'}\" ";
$gp_offer = &get_details($stp,__FILE__,__LINE__);
if($_[3] eq "metric") {
$dim_unit = "mm";
$wt_unit = "MT"
}
elsif($_[3] eq "fps") {
$dim_unit = "Inch";
$wt_unit = "Lbs"
}
if ((($_[8] ne "IN") && ($_[9] == 0))) {
$currency_type = "USD";
} else {
$currency_type = "Rs";
}
if($_[4] eq "view_offer_details" || $_[4] eq "send_purchase_order" || $_[4] eq "view_po" || $_[4] eq "view_oa" || $_[4] eq "view_invoice")
{
if($grade_product_details->{'price_mt'} ne $gp_offer->{'price_mt'}) {
$price_val = "$grade_product_details->{'price_mt'} ";
}
else{
$price_val = "$grade_product_details->{'price_mt'} ";
}
$price_html = "Price ($currency_type/$wt_unit) ";
$cols = 13;
if($_[4] eq "view_invoice") {
$amt_value = $grade_product_details->{'quantity'} * $grade_product_details->{'price_mt'};
$amt_val = "$amt_value ";
$amt_html = "Amount ($currency_type) ";
$cols = 14;
}
}
else {
$cols = 12;
}
if($grade_product_details->{'grade_id'} != 0) {
$g_name = &get_single_value("select $_[5] from grades where grade_id='$grade_product_details->{'grade_id'}'",__FILE__,__LINE__);
} else {
$g_name = "-";
}
###- This is due to show value highlighted which are chaged from offer to RFQ
###- ===========================================================
my (%key_hash_physical, @key_arr_physical, $key_arr_phy, $physical_html, @keys_of_hash_physical);
@keys_of_hash_physical = ('grade_id','product_id','surface_finish_id','edge_cond_id');
%key_hash_physical = (
'grade_id' => $g_name,
'product_id' => $p_name,
'surface_finish_id' => $s_f_name,
'edge_cond_id' => $e_c_name
);
@key_arr_physical = (thickness_nom,thickness_tol,width_nom,width_tol,length_nom,length_tol,coil_weight,quantity);
foreach $key_hash_phy (@keys_of_hash_physical) {
if($grade_product_details->{$key_hash_phy} ne $gp_offer->{$key_hash_phy})
{$physical_html .= " $key_hash_physical{$key_hash_phy} ";
}
else{
$physical_html .= " $key_hash_physical{$key_hash_phy} ";
}
}
foreach $key_arr_phy (@key_arr_physical) {
#### $physical_html .= "$grade_product_details->{$key_arr_phy} ";
if($grade_product_details->{$key_arr_phy} ne $gp_offer->{$key_arr_phy}) {
$physical_html .= " $grade_product_details->{$key_arr_phy} ";
}else{
$physical_html .= "$grade_product_details->{$key_arr_phy} ";
}
}
if($_[1] eq "no") {
$rfq_record_html = " $physical_html $price_val \n $amt_val ";
}
elsif($_[1] eq "yes")
{
my (@key_arr_chemical, @key_arr_mechnical, $chemical_html, $key_arr_chem, $key_arr_mech, $mechnical_html);
@key_arr_chemical = (C_amt,Mn_amt,P_amt,S_amt,Si_amt,Cr_min_amt,Cr_amt,Ni_min_amt,Ni_amt,Mo_min_amt,Mo_amt,N_amt,Cu_other_amt);
@key_arr_mechnical = (tensile_strength,yield_strength,elongation,hardness_bhn,hardness_rb);
foreach $key_arr_chem (@key_arr_chemical) {
if($grade_product_details->{$key_arr_chem} ne $gp_offer->{$key_arr_chem}) {
$chemical_html .= " $grade_product_details->{$key_arr_chem} ";
}
else{
$chemical_html .= "$grade_product_details->{$key_arr_chem} ";
}
#$chemical_html .= "$grade_product_details->{$key_arr_chem} ";
}
foreach $key_arr_mech (@key_arr_mechnical) {
if($grade_product_details->{$key_arr_mech} ne $gp_offer->{$key_arr_mech} ) {
$mechnical_html .= " $grade_product_details->{$key_arr_mech} ";
}
else{
$mechnical_html .= "$grade_product_details->{$key_arr_mech} ";
}
}
$rfq_record_html = qq~
Chemical Composition (In %)
C (Max)
Mn (Max)
P (Max)
S (Max)
Si (Max)
Cr
Ni
Mo
Nitrogen (Max)
Cu/Other
(Min)
(Max)
(Min)
(Max)
(Min)
(Max)
~;
$rfq_record_html .= " $chemical_html
";
$rfq_record_html .= qq~
Mechanical Composition
Tensile StrengthMpa(Min)
Yield Strength
% Age Elongation in 50 mm gauge length min
Hardness
(BHN)
(Rb)
~;
$rfq_record_html .= " $mechnical_html
";
$rfq_record_html .= qq~
Physical Composition
Grade
Product
Surface Finish
Edge Condition
Thickness ($dim_unit)
Width ($dim_unit)
Length ($dim_unit)
Coil/Pallet Weight ($wt_unit)
Quantity ($wt_unit)
$price_html
$amt_html
Nom.
Tol.
Nom.
Tol.
Nom.
Tol.
~;
$rfq_record_html .= " $physical_html $price_val \n $amt_val
";
}
return $rfq_record_html;
}
##########################################################
# Get javascript code to show S.F. & E.C. for a product #
#########################################################
sub get_sf_ec_js {
my ($related_val_html, $sf_html, $ec_html, $sf_html_back, $ec_html_back, $dim_html, $parr, %phash, $dimension_html);
$related_val_html = "";
return $related_val_html;
}
#################################################################
###########################################################################
# Get javascript code to show S.F. & E.C. for a product in Offer form #
############################################################################
sub get_sf_ec_js1{
#get_offer_js {
my ($offer_html, $sf_html, $ec_html, $sf_html_back, $ec_html_back, $dim_html, $parr, %phash, $dimension_html);
$offer_html = "";
return $offer_html;
}
sub get_sf_ec_js111 {
my ($related_val_html, $sf_html, $ec_html, $sf_html_back, $ec_html_back, $dim_html, $parr, %phash, $dimension_html);
my $surface_finish_id='surface_finish_id'.$count;
my $edge_cond_id ='edge_cond_id'.$count;
my $product_id = 'product_id'.$count;
my $length_nom = 'length_nom'.$count;
my $length_tol ='length_tol'.$count;
my $coil_weight='coil_weight'.$count;
my $surface_finish_id='surface_finish_id'.$count;
my $coil_weight='coil_weight'.$count;
$related_val_html = "";
return $related_val_html;
}
###########################################################
# View for the offer existance & show accordingly #
###########################################################
sub view_offer_user {
my ($offer_details, $enq_details, @grade_product_offer_array, $offer_view_html, @return_view_offer);
$offer_details = &get_details("select * from offer_record where offer_no = '$_[0]'",$_[2],$_[3]);
$enq_details = &get_details("select * from enquiry_record where enq_no = '$offer_details->{'enq_no'}'",$_[2],$_[3]);
if($offer_details ne "") {
@grade_product_offer_array = &get_id_array("select grade_product_offer_no from offer_record_to_grade where offer_no = '$_[0]'",$_[2],$_[3]);
if($#grade_product_offer_array != -1)
{
my $i = 0;
foreach $grade_product_offer_array (@grade_product_offer_array)
{
my $st = "select * from grade_product_offer where grade_product_offer_no = '$grade_product_offer_array'";
$offer_view_html .= &get_rfq_record_html($st,$enq_details->{'grade_option'},$_[0],$enq_details->{'unit_type'},$_[1],$enq_details->{'grade_country'},$_[2],$_[3],$enq_details->{'country_id'},$enq_details->{'state_id'});
$i++;
}
}
}
@return_view_offer = ($offer_details,$#grade_product_offer_array,$offer_view_html);
return @return_view_offer;
}
sub view_offer_user1 {
my ($offer_details, $enq_details, @grade_product_offer_array, $offer_view_html, @return_view_offer);
$offer_details = &get_details("select * from offer_record where offer_no = '$_[0]'",$_[2],$_[3]);
$enq_details = &get_details("select * from enquiry_record where enq_no = '$offer_details->{'enq_no'}'",$_[2],$_[3]);
if($offer_details ne "") {
@grade_product_offer_array = &get_id_array("select grade_product_offer_no from offer_record_to_grade where offer_no = '$_[0]'",$_[2],$_[3]);
if($#grade_product_offer_array != -1)
{
my $i = 0;
foreach $grade_product_offer_array (@grade_product_offer_array)
{
my $st = "select * from grade_product_offer where grade_product_offer_no = '$grade_product_offer_array'";
$offer_view_html .= &get_rfq_record_html1($st,
$enq_details->{'grade_option'},
$_[0],
$enq_details->{'unit_type'},
$_[1],
$enq_details->{'grade_country'},
$_[2],
$_[3],
$enq_details->{'country_id'},
$enq_details->{'state_id'},
$i);
$i++;
}
}
}
@return_view_offer = ($offer_details,$#grade_product_offer_array,$offer_view_html);
#print " $offer_view_html ";
#exit;
return @return_view_offer;
}
sub view_po {
#my ($offer_details, $enq_details, @grade_product_offer_array, $offer_view_html, @return_view_offer);
$offer_details = &get_details("select * from offer_record where offer_no =\'$po_details->{'offer_no'}\'",$_[2],$_[3]);
$enq_details = &get_details("select * from enquiry_record where enq_no = '$offer_details->{'enq_no'}'",$_[2],$_[3]);
if($offer_details ne "") {
@grade_product_po_array = &get_id_array("select grade_product_po_no from po_record_to_grade where po_no = '$_[0]'",$_[2],$_[3]);
#print "@grade_product_po_array select grade_product_po_no from po_record_to_grade where po_no = '$_[0]' ";exit;
if($#grade_product_po_array != -1)
{
my $i = 0;
foreach $grade_product_po_array (@grade_product_po_array)
{
my $st = "select * from grade_product_po where grade_product_po_no = '$grade_product_po_array'";
$offer_view_html .= &get_rfq_record_html1($st,
$enq_details->{'grade_option'},
$_[0],
$enq_details->{'unit_type'},
$_[1],
$enq_details->{'grade_country'},
$_[2],
$_[3],
$enq_details->{'country_id'},
$enq_details->{'state_id'},
$i);
$i++;
}
}
}
@return_view_offer = ($offer_details,$#grade_product_po_array,$offer_view_html);
#print " select * from offer_record where offer_no = '$po_details->{'offer_no'}
#$offer_details, qqqqqq $#grade_product_po_array, ssssss $offer_view_html ";
#exit;
return @return_view_offer;
}
sub view_oa {
my ($oa_details, $enq_details, @grade_product_oa_array, $oa_view_html, @return_view_oa);
my $oa_details = &get_details("select * from order_acceptance where oa_no =\'$_[0]\'",$_[2],$_[3]);
$details = &get_details("select offer_no from purchase_order where po_no =\'$oa_details->{'po_no'}\'",$_[2],$_[3]);
$offer_details = &get_details("select * from offer_record where offer_no =\'$details->{'offer_no'}\'",$_[2],$_[3]);
$enq_details = &get_details("select * from enquiry_record where enq_no = '$offer_details->{'enq_no'}'",$_[2],$_[3]);
if($oa_details ne "") {
@grade_product_oa_array = &get_id_array("select grade_product_oa_no from oa_record_to_grade where oa_no = '$_[0]'",$_[2],$_[3]);
if($#grade_product_oa_array != -1)
{
my $i = 0;
foreach $grade_product_oa_array (@grade_product_oa_array)
{
my $st = "select * from grade_product_oa where grade_product_oa_no = '$grade_product_oa_array'";
$oa_view_html .= &get_rfq_record_html_oa($st,
$enq_details->{'grade_option'},
$_[0],
$enq_details->{'unit_type'},
$_[1],
$enq_details->{'grade_country'},
$_[2],
$_[3],
$enq_details->{'country_id'},
$enq_details->{'state_id'},
$i);
$i++;
}
}
}
@return_view_oa = ($oa_details,$#grade_product_oa_array,$oa_view_html,$offer_details->{'enq_no'});
return @return_view_oa;
}
#-######################################
#- Get the all id's value of a table #
#-######################################
sub get_id_array
{
my($st, $sth, $id_val, $i, @id_val_arr);
$i = 0;
$st = $_[0];
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
while($id_val = $sth->fetchrow_array)
{
### This check, i implemented for submit_po case in checking po_no for every offer. If any problem
### arises then check it again.
if($id_val ne "") {
$id_val_arr[$i++] = $id_val;
}
}
$sth->finish;
#print " @id_val_arr " ;
return @id_val_arr;
}
##############################################
# Insert value in table & return created id #
##############################################
sub insert_val
{
my ($st, $sth, $in_id);
$st = $_[0];
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
if (!($sth->execute)){
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
##$in_id = $sth->{insertid};
$in_id = $dbh->{mysql_insertid};
$sth->finish;
return $in_id;
}
###########################
# Update value in table #
###########################
sub update_val
{
my ($st, $sth);
$st = $_[0];
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
if (!($sth->execute)){
dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
$sth->finish;
}
###########################
# Change Date Format #
###########################
sub change_date_format
{
my @date_arr = split(/-/,$_[0]);
$date_arr[1] =~ s/^0//;
my $new_date = "$date_arr[2]-$mon_val{$date_arr[1]}-$date_arr[0]";
return $new_date;
}
#-#######################################################
#- Get all records from temp table to edit it in preview form #
#-#######################################################
sub get_temp_rfqpreview_html
{
my($temp_grade_product_details, $g_html, $p_html, $sf_html, $ec_html, @psf_ids, $psf_id, @pec_ids, $pec_id);
my($temp_rfq_record_html, $check_html, $check_text_ns, $col_val, $dim_unit, $wt_unit);
$temp_grade_product_details = &get_details("select * from temp_grade_product_enquiry where temp_grade_product_no = '$_[0]'",$_[7],$_[8]);
$g_html = &get_selected_value_html("select * from grades where grade_status = 'yes'","grade_id","$_[6]","Grade",$temp_grade_product_details->{'grade_id'},"grade_id$_[5]",$_[7],$_[8]);
###$p_html = &get_selected_value_html("select * from products where product_status = 'yes'","product_id","product_name","Product",$temp_grade_product_details->{'product_id'},"product_id$_[5]",$_[7],$_[8]);
$p_html = &get_selected_product_html($temp_grade_product_details->{'product_id'},$_[5]);
@psf_ids = &get_id_array("select surface_finish_id from products_surface_finish where product_id='$temp_grade_product_details->{'product_id'}'",$_[7],$_[8]);
$sf_html = "Select Finish ";
foreach $psf_id (@psf_ids)
{
my $sf_name = &get_single_value("select surface_finish_name from surface_finish where surface_finish_id='$psf_id'",$_[7],$_[8]);
if($psf_id == $temp_grade_product_details->{'temp_surface_finish_id'}) {
$sf_html .= "$sf_name ";
} else {
$sf_html .= "$sf_name ";
}
}
$sf_html .= " ";
@pec_ids = &get_id_array("select edge_cond_id from products_edge_condition where product_id='$temp_grade_product_details->{'product_id'}'",$_[7],$_[8]);
$ec_html = "Select Edge ";
foreach $pec_id (@pec_ids)
{
my $ec_name = &get_single_value("select edge_cond_name from edge_condition where edge_cond_id='$pec_id'",$_[7],$_[8]);
if($pec_id == $temp_grade_product_details->{'temp_edge_cond_id'}) {
$ec_html .= "$ec_name ";
} else {
$ec_html .= "$ec_name ";
}
}
$ec_html .= " ";
if($_[3] eq "metric") {
$dim_unit = "mm";
$wt_unit = "MT"
}
elsif($_[3] eq "fps") {
$dim_unit = "Inch";
$wt_unit = "Lbs"
}
if($_[4] eq "proc_rfq") {
$check_html = " ";
$check_text_ns = "Uncheck to delete ";
$col_val = 13;
}
else {
$col_val = 12;
}
if($_[1] eq "no") {
$temp_rfq_record_html = qq~
$g_html
$p_html
$sf_html
$ec_html
$check_html
~;
}
elsif($_[1] eq "yes")
{
$temp_rfq_record_html = qq~
~;
}
##print " $temp_rfq_record_html ";
return $temp_rfq_record_html;
}
############################################################################
# get all values from any table to show in drop down with selected particular value #
############################################################################
sub get_selected_value_html
{
my($st, $sth, $value_details, $value_html);
$st = $_[0];
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st,$_[6],$_[7]);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st,$_[6],$_[7]);
}
$value_html = "Select $_[3] ";
while($value_details = $sth->fetchrow_hashref)
{
my $id = $value_details->{$_[1]};
if($id == $_[4]) {
$value_html .= "$value_details->{$_[2]} ";
}
else {
$value_html .= "$value_details->{$_[2]} ";
}
}
$sth->finish;
$value_html .= " ";
return $value_html;
}
sub get_selected_value_html1
{
my($st, $sth, $value_details, $value_html);
$st = $_[0];
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st,$_[6],$_[7]);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st,$_[6],$_[7]);
}
$value_html = "Select $_[3]";
while($value_details = $sth->fetchrow_hashref)
{
my $id = $value_details->{$_[1]};
if($id == $_[4]) {
$value_html .= "$value_details->{$_[2]} ";
}
else {
$value_html .= "$value_details->{$_[2]} ";
}
}
$sth->finish;
$value_html .= " ";
return $value_html;
}
####################
# Get the date selected
####################
sub get_selected_date
{
my ($dt, $date_html);
$date_html = "";
foreach $dt (1..31) {
if($dt == $_[0]) {
$date_html .= "$dt ";
}
else {
$date_html .= "$dt ";
}
}
$date_html .= " ";
return $date_html;
}
############################################################################
# Get javascript code to show S.F. & E.C. for a product in preview form #
############################################################################
sub get_preview_js {
my ($preview_html, $sf_html, $ec_html, $sf_html_back, $ec_html_back, $dim_html, $parr, %phash, $dimension_html);
$preview_html = "";
return $preview_html;
}
###########################
# Get Date Difference #
###########################
sub get_date_diff
{
##- Dates are in YYYY-MM-DD format
my @date0 = split(/-/,$_[0]);
my @date1 = split(/-/,$_[1]);
##- Deduct 1 from month naumber, as we are inserting & fetching month number in (1 - 12) fromat
##- while these function takes from 0-11.
my $mon0 = $date0[1] - 1;
my $mon1= $date1[1] - 1;
my $date0_sec = timegm(0,0,0,$date0[2],$mon0,$date0[0]);
my $date1_sec = timegm(0,0,0,$date1[2],$mon1,$date1[0]);
my $date_diff = $date0_sec - $date1_sec;
return $date_diff;
}
#####################################################################################
# get_drop_down
# Function to print the drop down for given set of values
# Input
# - File Name
# - Line Number
# - Table Name
# - The field whose values will be the actual values of each option in dropwown
# - The fields whose values will be displayed
# The field is a string and its value can be field1,field2,..
# - Default text, as the first displayable TEXT in dropdown
# - The id of the value that has to be displayed as SELECTED
# - name of the dropwown
# - If passed, SELECT text in first element of dropwown will NOT be printed
# - where clause(part of query)
# - $dbh
# - If any function is to call for select
# (__FILE__,__LINE__,"state","state_id","state_name","State","$user_details->{'state'}","state","","",$dbh,$select_function)
# Returns
# - Prepared code for the dropwown
#####################################################################################
sub get_drop_down {
my($st, $sth, $field_details, $field_list_html, $dbh, $select_name, $table, $id_name, $name, $default_text, $select_value, @name, $if_not_print_select, $where, $file, $line, $select_function);
$file = $_[0];
$line = $_[1];
$table = $_[2];
$id_name = $_[3];
$name = $_[4];
$default_text = $_[5];
$select_value = $_[6];
$select_name = $_[7];
$if_not_print_select = $_[8];
$where = $_[9];
$dbh = $_[10];
$select_function = $_[11];
if ($name =~ /,/) {
@name=split(/,/,$name);
}
$st = "select * from $table";
if($where){
$st .= ' ' . $where;
}
$sth = $dbh->prepare($st);
if (!($sth)) {
&dataerror($dbh->errstr.$st,$_[0],$_[1]);
}
if (!($sth->execute)) {
&dataerror($dbh->errstr.$st,$_[0],$_[1]);
}
$field_list_html = "\n";
if ($if_not_print_select) {
$field_list_html .= "-- $default_text -- \n";
}
else {
$field_list_html .= "-- Select $default_text -- \n";
}
while($field_details = $sth->fetchrow_hashref)
{
my $cid = $field_details->{$id_name};
my $temp_value;
if (@name) {
foreach (@name) {
if (!($temp_value)) {
$temp_value = $field_details->{$_};
} else {
$temp_value .= ",\t" . $field_details->{$_};
}
}
}
else {
$temp_value = $field_details->{$name};
}
if($select_value eq "") {
$field_list_html .= "$temp_value \n";
}
else{
if ($cid eq $select_value) {
$field_list_html .= "$temp_value \n";
}
else {
$field_list_html .= "$temp_value \n";
}
}
}
$sth->finish;
$field_list_html .= " \n";
return $field_list_html;
}
#-##########################################################
# Sub: Check user cookie, if not send to login page
#-##########################################################
sub check_login {
my $oldcookie = $q->cookie("$config{'cookiename'}");
if(!$oldcookie) {
print "Content-type: text/html\n\n";
&print_filecontent($config{'headerfile'});
print qq~
~;
&print_filecontent($config{'footerfile'});
exit;
} ##- end if
return true;
}
#-##########################################################
# Sub: Validate username/password, finally send it to proper action page
#-##########################################################
sub validate_login {
my $user = $_[0];
my $pass = $_[1];
&oops('You must enter an user id that consists of alphanumeric characters only.') if $user =~ /\W/ or !($user);
&oops('You must enter a password.') unless ($form{'password'});
&oops('You must enter a password that consists of alphanumeric characters only.') if $pass =~ /\W/ ;
######## code to check whether any user of this name already exists or not.
my $st = "select userid from members where (username='$user' and password = '$pass' and (user_type = 'buyer' or user_type = 'both'))";
my $login_details = &get_details($st,__FILE__,__LINE__);
if($login_details eq "") {
print "Content-type: text/html\n\n";
&print_filecontent($config{'headerfile'});
print "Your login encountered the following problem :
Either Invalid username and password Or You don't have buyer's permission.
Please try again.
Return to Index page ";
&print_filecontent($config{'footerfile'});
exit;
}# end if
my $jcookie = $login_details->{'userid'};
my $packed_cookie = $q->cookie( -NAME => "$config{'cookiename'}",-VALUE => "$jcookie");
print $q->header(-COOKIE => $packed_cookie);
return $jcookie;
}
##=================================================
##- Main Program
##=================================================
sub main_user {
my $field = $_[0];
my $user = $_[1];
my $pass = $_[2];
my $key_match = 0;
foreach my $keys(keys %form) {
if ($keys eq $field) {
$key_match = 1;
last;
}
}
if ($key_match != 1) {
&check_login();
}
&Db_connect();
##===============================================================
##- Check whether use is valid or not for a given password & username
my $loginid;
if ($key_match == 1) {
$loginid = &validate_login($user,$pass);
}
##===============================================================
return $loginid;
}
sub get_grade_html1
{
my $grade_id=shift;
my $count=shift;
my($st, $sth, %grade_details, $grade_html);
#$st = "select * from grades where (grade_status = 'yes' && $_[0] != '')";
$st = "select * from grades where grade_status = 'yes' ";
$sth = $dbh->prepare($st);
if (!($sth)) {
print "$dbh->errstr.$st";
#dataerror($dbh->errstr.$st,$_[1],$_[2]);
}
if (!($sth->execute)) {
#dataerror($dbh->errstr.$st,$_[1],$_[2]);
print "$dbh->errstr.$st";
}
$grade_html = "Grade ";
while($grade_details = $sth->fetchrow_hashref)
{
my $id = $grade_details->{'grade_id'};
if($grade_id == $grade_details->{'grade_id'}){
$grade_html .= "$grade_details->{'grade_jindal'} ";
}
else{
$grade_html .= "$grade_details->{'grade_jindal'} ";
}
}
$sth->finish;
$grade_html .= " ";
return $grade_html;
}
#####################################################################################
# get all S.F. from SF table corr. to pid to show in drop down with selected option #
#####################################################################################
sub get_selected_sf_html
{
my(@psf_arr, $sf_html);
@psf_arr = &get_id_array("select surface_finish_id from products_surface_finish where product_id = '$_[0]'");
$sf_html = "";
foreach $psf_arr (@psf_arr) {
my $sf_name = &get_single_value("select surface_finish_name from surface_finish where surface_finish_id = '$psf_arr'");
if($psf_arr == $_[1]) {
$sf_html .= "$sf_name ";
}
else {
$sf_html .= "$sf_name ";
}
}
$sf_html .= " ";
return $sf_html;
}
#####################################################################################
# get all E.C. from EC table corr. to pid to show in drop down with selected option #
#####################################################################################
sub get_selected_ec_html
{
my($st, $sth, @pec_arr, $ec_html);
@pec_arr = &get_id_array("select edge_cond_id from products_edge_condition where product_id = '$_[0]'");
$ec_html = "";
foreach $pec_arr (@pec_arr) {
my $ec_name = &get_single_value("select edge_cond_name from edge_condition where edge_cond_id = '$pec_arr'");
if($pec_arr == $_[1]) {
$ec_html .= "$ec_name ";
}
else {
$ec_html .= "$ec_name ";
}
}
$ec_html .= " ";
return $ec_html;
}
##############################################
# Insert value in table & return created id #
##############################################
#####################################################################
#
# Function to make the HTML code for dropdown having numeric values
# Input
# - Class Name (undefault) /blank
# - Name of the dropdown
# - What is to be shown at the top/start of dropdown
# - Default value
# - Initial value
# - Final value
# - Step
# Returns
# - Dropdown for the values according to passed parameters
######################################################################
sub count_dropdown {
my($st,$sth,$dbh,$class,$dropdown_name,$default_text,$default_value,$initial_value,$final_value,$dropdown_html,$i,$step);
$dropdown_name = $_[1];
$default_text = $_[2];
$default_value = $_[3];
$initial_value = $_[4];
$final_value = $_[5];
if (!($default_text)) {
$default_text = "Select";
}
$dropdown_html = "\n";
$dropdown_html .= "-- $default_text -- \n";
$step = $_[6];
if(!$step || $step eq ""){
$step=1;
}
for ($i=$initial_value; $i<=$final_value;$i=$step+$i) {
#if ($i =~ /^\d$/) { $i= "0" . $i; }
if($default_value eq "") {
$dropdown_html .= "$i \n";
}
else {
if ($default_value eq $i) {
$dropdown_html .= "$i \n";
}
else {
$dropdown_html .= "$i \n";
}
}
}
$dropdown_html .= " \n";
return $dropdown_html;
}
#####################################################################################
#########################################################
# Get javascript code to show state for India #
#########################################################
sub get_cport_js {
my ($cport_html, %state_val, $state_id, $form_name);
$form_name = $_[0];
my($st, $sth, %state_val, %ctry);
$st = "select * from sea_port order by sea_port_name";
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st);
}
while($state_details = $sth->fetchrow_hashref)
{
my $sid = $state_details->{'sea_port_id'};
my $sname = $state_details->{'sea_port_name'};
$state_val{$sid} = $sname;
$ctry{$sid} = $state_details->{'fk_country_id'};
}
$sth->finish;
$cport_html = "";
return $cport_html;
}
################################################
# get all the country list in select drop down #
################################################
sub get_selected_country_list_cport
{
my($st, $sth, $selected_country_details);
$st = "select distinct country_id,country_name from country, sea_port where sea_port.fk_country_id = country.country_id order by country_no";
$sth = $dbh->prepare($st);
if (!($sth)) {
dataerror($dbh->errstr.$st);
}
if (!($sth->execute)) {
dataerror($dbh->errstr.$st);
}
###$country_list_html = "";
$country_list_html_cport = "";
while($selected_country_details = $sth->fetchrow_hashref)
{
my $cid = $selected_country_details->{'country_id'};
if($cid eq $_[0] ) {
$country_list_html_cport .= "$selected_country_details->{'country_name'} ";
} else {
$country_list_html_cport .= "$selected_country_details->{'country_name'} ";
}
}
if ($_[0] eq 'other') {
$country_list_html_cport .= "other ";
}else {
$country_list_html_cport .= "other ";
}
#$country_list_html_cport .= "$selected_country_details->{'country_name'} ";
$sth->finish;
$country_list_html_cport .= " ";
return $country_list_html_cport;
}