2024-10-16 19:18:52 +05:30
< ? php
include ( 'includes/config/config.php' );
include ( " includes/functions.php " );
$Id = $_REQUEST [ 'Id' ];
$request_type = $_REQUEST [ 'request_type' ];
$itr = $_REQUEST [ 'itr' ];
if ( ! isset ( $itr ) || $itr == 'undefined' ){
$itr = " " ;
}
switch ( $request_type )
{
case 'getSubcat' :
$sql = " SELECT cat_id, cat_name FROM tbl_categories where parent_id<>'0' AND parent_id=' " . $Id . " ' " ;
$subcat = " <select name='subcat " . $itr . " ' id='subcat " . $itr . " ' class='selectbox' onchange= \" getItems(this.value,'item_list " . $itr . " ',' " . $itr . " '); \" /> " ;
$res = mysqli_query ( $conn , $sql );
$subcat .= " <option value='' >Select One</option> " ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$subcat .= " <option value=' " . $rows [ cat_id ] . " ' > " . $rows [ cat_name ] . " </option> " ;
}
$subcat .= '</select>' ;
echo $subcat ;
break ;
case 'getSubcats' :
$sql = " SELECT cat_id, cat_name FROM tbl_categories where parent_id<>'0' AND parent_id=' " . $Id . " ' " ;
$subcat = " " ;
$res = mysqli_query ( $conn , $sql );
$subcat .= " <option value='' >Select One</option> " ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$subcat .= " <option value=' " . $rows [ cat_id ] . " ' > " . $rows [ cat_name ] . " </option> " ;
}
echo $subcat ;
break ;
case 'getSubcats_pp' :
$sql1 = " SELECT a.cat_id, a.cat_name FROM tbl_categories a, tbl_categories b WHERE b.cat_id=a.parent_id AND a.parent_id=(select cat_id FROM tbl_categories WHERE cat_name=' " . $Id . " ') " ;
$subcat1 = " " ;
$res1 = mysqli_query ( $conn , $sql1 );
$subcat1 .= " <option value='%' >ALL</option> " ;
while ( $rows1 = mysqli_fetch_array ( $res1 ))
{
$subcat1 .= " <option value=' " . $rows1 [ cat_id ] . " ' > " . $rows1 [ cat_name ] . " </option> " ;
}
//$subcat.='</select>';
echo $subcat1 ;
break ;
case 'getCats' :
$sql = " SELECT a.cat_name FROM tbl_categories a LEFT JOIN tbl_items b ON a.cat_id=b.cat WHERE b.item_name=' " . $Id . " ' " ;
$subcat = " " ;
$res = mysqli_query ( $conn , $sql );
$subcat .= " <option value='%' >ALL</option> " ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$subcat .= " <option value=' " . $rows [ cat_name ] . " ' > " . $rows [ cat_name ] . " </option> " ;
}
//$subcat.='</select>';
echo $subcat ;
break ;
case 'getItems' :
$sql = " SELECT item_id, item_name FROM tbl_items where subcat=' " . $Id . " ' or cat = ' " . $Id . " ' " ;
$items = " <select name='item_Name " . $itr . " ' id='item_Name " . $itr . " ' class='selectbox' onchange= \" getItemdet(this.value,'item_Description " . $itr . " ','pl_no " . $itr . " ') \" /> " ;
$res = mysqli_query ( $conn , $sql );
$items .= " <option value='0' >Select One</option> " ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$items .= " <option value=' " . $rows [ item_id ] . " ' > " . $rows [ item_name ] . " </option> " ;
}
$items .= '</select>' ;
echo $items ;
break ;
case 'getDrawingAlteration' :
$sql = " SELECT alteration_no FROM drawing_alteration where drawing_id=' " . $Id . " ' " ;
//echo $sql;
$t = " if(this.value=='addnew')window.open('dr_fly.php?acn=update&itr= " . $itr . " &drawing_id= " . $Id . " ','mywindow','menubar=0,resizable=0,status=0,scrollbars=1,width=700,height=500') " ;
$drawing_alterations = " <select onChange= " . $t . " class='selectbox' id='drawing_alteration " . $itr . " ' name='drawing_alteration " . $itr . " ' \" /> " ;
$res = mysqli_query ( $conn , $sql );
$drawing_alterations .= " <option value='0' >Select One</option> " ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$drawing_alterations .= " <option value=' " . $rows [ alteration_no ] . " ' > " . $rows [ alteration_no ] . " </option> " ;
}
$drawing_alterations .= " <option value='addnew'>Other...</option> " ;
$drawing_alterations .= '</select>' ;
echo $drawing_alterations ;
break ;
case 'getDrawings' :
$sql = " SELECT * FROM tbl_drawing_detail " ;
$t = " if(this.value=='addnew') { window.open('dr_fly.php?acn=add&itr= " . $itr . " ','mywindow','menubar=0,resizable=0,status=0,scrollbars=1,width=700,height=500')}getDrawingAlteration(this.value,'drawing_alterations " + itr + " ', " + itr + " ) " ;
$drawing_details = " <select onChange= " . $t . " class='selectbox' id='drawing_details " . $itr . " ' name='drawing_details " . $itr . " ' \" /> " ;
$res = mysqli_query ( $conn , $sql );
$drawing_details .= " <option value='0' >Select One</option> " ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$drawing_details .= " <option value=' " . $rows [ 'drawing_id' ] . " ' > " . $rows [ 'drawing_details' ] . " </option> " ;
}
$drawing_details .= " <option value='addnew'>Other...</option> " ;
$drawing_details .= '</select>' ;
echo $drawing_details ;
break ;
case 'getItemdesc' :
$sql = " SELECT item_name FROM tbl_items where item_id=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$rows = mysqli_fetch_array ( $res );
$itemdes = $rows [ 'item_name' ];
echo $itemdes ;
break ;
case 'getItemdet' :
$sql = " SELECT item_name, pl_no FROM tbl_items where item_id=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$rows = mysqli_fetch_array ( $res );
$itemdes = $rows [ 'item_name' ];
$itempl = $rows [ 'pl_no' ];
echo $itemdes ;
break ;
case 'getPldet' :
$sql = " SELECT pl_no FROM tbl_tender_items where item_id=' " . $Id . " ' AND pl_no<>'' AND pl_no is not NULL " ;
$res = mysqli_query ( $conn , $sql );
$output = '<select name="pl_no' . $itr . '" class="selectbox" onchange="addnewpl(this.value,' . $itr . ');" >' ;
$count = 0 ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$output .= " <option value=' " . $rows [ pl_no ] . " ' > " . $rows [ pl_no ] . " </option> " ;
}
$output .= '<option value="addnew">Other.....</option>' ;
$output .= '</select>' ;
echo $output ;
break ;
case 'getBothCat' :
$sql = " SELECT item_name,cat,subcat FROM tbl_items where item_id=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$rows = mysqli_fetch_array ( $res );
$CatRow = mysqli_query ( $conn , " select cat_name from tbl_categories where cat_id = " . $rows [ 'cat' ]);
$CatRow = mysqli_fetch_array ( $CatRow );
$output = $CatRow [ 'cat_name' ];
$subCatRow = mysqli_query ( $conn , " select cat_name from tbl_categories where cat_id = " . $rows [ 'subcat' ]);
$subCatRow = mysqli_fetch_array ( $subCatRow );
$output = $output . " ## " . $subCatRow [ 'cat_name' ] . " ## " . $rows [ 'item_name' ];
echo $output ;
break ;
case 'listQuoteItems' :
$sql = " SELECT * FROM tbl_tender_items where tender_no=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$output = '' ;
$count = 0 ;
while ( $rows = mysqli_fetch_array ( $res ))
{
@ extract ( $rows );
$sql2 =@ mysqli_query ( $conn , " SELECT a.*, b.cat_name as cat,c.cat_name as subcat FROM tbl_items a LEFT JOIN tbl_categories b ON a.cat=b.cat_id LEFT JOIN tbl_categories c on a.subcat=c.cat_id WHERE a.item_id=' " . $rows [ 'item_id' ] . " ' " );
$row =@ mysqli_fetch_array ( $sql2 );
if ( @ mysqli_num_rows ( $sql2 ))
{
@ extract ( $row );
$output .= '<tr>' ;
$output .= '<td><input name="chk$count" type="checkbox" /></td>' ;
$output .= '<td><input type="text" class="textbox1" name="item_Name$count" id="item_Name$count" value="' . stripslashes ( $item_name ) . '" readonly/></td>' ;
$output .= '<td><input type="text" class="textbox1" size=8 name="item_Category$count" id="item_Category$count" value="' . $cat . '" readonly></td>' ;
$output .= '<td><input type="text" class="textbox1" size=8 name="item_SubCategory$count" id="item_SubCategory$count" value="' . $subcat . '" readonly /></td>' ;
$output .= '<td><input type="text" class="textbox1" name="item_Qty$count" value="' . $item_qty . '" size="5"></td>' ;
$output .= '<td><input type="text" class="textbox1" name="item_Rate$count" value="" size="5"></td>' ;
$output .= '<td><input type="text" class="textbox1" name="item_Packaging$count" size="8"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_Ed$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_Cst$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_Frieght$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_Insurance$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_Forwarding$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_Commisioning$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_InstallationCharges$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_OtherCharges$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_TotalRates$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=5 name="item_For$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=8 name="item_Inspection$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=8 name="item_DeliveryShedule$count"></td>' ;
$output .= '<td><input type="text" class="textbox1" size=8 name="item_Remarks$count" value="' . $item_remarks . '"></td>' ;
$output .= '</tr>' ;
$count ++ ;
}
else
$output = " No Records Found " ;
}
echo $output ;
break ;
case 'listClientLocations' :
$sql = " SELECT * FROM client_details where client_id=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$output = '<select name="client_location_id" class="selectbox" />' ;
$count = 0 ;
while ( $rows = mysqli_fetch_array ( $res ))
{
$output .= " <option value=' " . $rows [ location_id ] . " ' > " . $rows [ client_City ] . " </option> " ;
}
$output .= '</select>' ;
echo $output ;
break ;
case 'createInternalRef' :
$sql = " SELECT firm_code FROM tbl_firms where firm_id=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$rows = mysqli_fetch_array ( $res );
$firm_code = $rows [ 'firm_code' ];
$sql1 = " SELECT internal_ref_no FROM quotation_master where firm_id=' " . $Id . " ' " ;
$res1 = mysqli_query ( $conn , $sql1 );
$i = 0 ;
while ( $rows1 = mysqli_fetch_array ( $res1 ))
{
$str = $rows1 [ 'internal_ref_no' ];
2024-11-19 09:59:09 +05:30
if ( is_string ( $str )) {
$pos1 = strpos ( $str , " / " );
$pos2 = strripos ( $str , " / " );
} else {
// Handle the case where $str is not a string
$pos1 = false ;
$pos2 = false ;
}
2024-10-16 19:18:52 +05:30
$ref_no [ $i ] = substr ( $str , $pos1 + 1 , $pos2 - $pos1 - 1 );
$i ++ ;
}
if ( $ref_no ){
$max = max ( $ref_no ) + 1 ;
}
else {
$max = 1 ;
}
$output = $firm_code . " / " . $max . " / " . date ( 'Y' );
echo $output ;
break ;
case 'createProdFileNo' :
$sql = " SELECT firm_code FROM tbl_firms where firm_id=' " . $Id . " ' " ;
$res = mysqli_query ( $conn , $sql );
$rows = mysqli_fetch_array ( $res );
$firm_code = $rows [ 'firm_code' ];
$sql1 = " SELECT production_file_no FROM purchase_order_master where firm_id=' " . $Id . " ' " ;
$res1 = mysqli_query ( $conn , $sql1 );
$i = 0 ;
if ( $res1 ){
while ( $rows1 = mysqli_fetch_array ( $res1 ))
{
$str = $rows1 [ 'production_file_no' ];
$pos1 = strpos ( $str , " / " );
$pos2 = strripos ( $str , " / " );
$ref_no [ $i ] = substr ( $str , $pos1 + 1 , $pos2 - $pos1 - 1 );
$i ++ ;
}
}
if ( $ref_no ){
$max = max ( $ref_no ) + 1 ;
}
else {
$max = 1 ;
}
$output = " PFN_ " . $firm_code . " / " . $max . " / " . date ( 'Y' );
echo $output ;
break ;
case 'getPP_Item_details' :
$sql_cat = " SELECT cat_id, cat_name FROM tbl_categories WHERE cat_id IN (SELECT DISTINCT(cat) FROM tbl_items WHERE item_name=' " . $Id . " ') " ;
//echo $sql_cat;
$res_cat = mysqli_query ( $conn , $sql_cat );
$output = '' ;
while ( $rows_cat = mysqli_fetch_array ( $res_cat ))
{
$output .= " <tr> " ;
$output .= " <td><table class= \" bdr_table \" > " ;
$output .= " <tr> " ;
$output .= " <td align= \" right \" class= \" VerdanaBiggerBlack \" width= \" 10px \" > " ;
$output .= " <input type= \" checkbox \" value= \" true \" name= \" " . $rows_cat [ 'cat_name' ] . " \" /> " ;
$output .= " </td> " ;
$output .= " <td class= \" VerdanaBiggerBlack \" > " . $rows_cat [ 'cat_name' ] . " </td> " ;
$output .= " </tr> " ;
//end of material checkbox
//open a new tr to include submaterial and specs
//start of submaterial
$sql_subcat = " SELECT cat_id, cat_name FROM tbl_categories WHERE parent_id=' " . $rows_cat [ 'cat_id' ] . " ' " ;
//echo $sql_subcat;
$res_subcat = mysqli_query ( $conn , $sql_subcat );
$subcat_output = " " ;
$subcat_output .= " <tr> " ;
$subcat_output .= " <td class= \" bdr_td \" > </td> " ;
$subcat_output .= " <td class= \" bdr_td \" > " ;
$subcat_output .= " <table id= \" submaterial0 \" width= \" 100% \" class= \" bdr_table \" > " ;
while ( $rows_subcat = mysqli_fetch_array ( $res_subcat ))
{
$subcat_output .= " <tr> " ;
$subcat_output .= " <td align= \" right \" class= \" VerdanaMediumBlack \" width= \" 10px \" > " ;
$subcat_output .= " <input type= \" checkbox \" value= \" true \" name= \" subcat_ " . $rows_subcat [ 'cat_name' ] . " \" /> " ;
$subcat_output .= " </td> " ;
$subcat_output .= " <td class= \" VerdanaBigBlack \" > " . $rows_subcat [ 'cat_name' ] . " </td> " ;
$subcat_output .= " </tr> " ;
//end of submaterial checkbox
//open a new tr to include specs
//start of specs
$sql_spec = " SELECT item_id,item_desc,item_spec FROM tbl_items WHERE cat=' " . $rows_cat [ 'cat_id' ] . " ' and subcat=' " . $rows_subcat [ 'cat_id' ] . " ' " ;
//echo $sql_spec;
$res_spec = mysqli_query ( $conn , $sql_spec );
$spec_output = " " ;
$spec_output .= " <tr> " ;
$spec_output .= " <td class= \" bdr_td \" > </td> " ;
$spec_output .= " <td class= \" bdr_td \" > " ;
$spec_output .= " <table id= \" spec0 \" width= \" 100% \" class= \" bdr_table \" > " ;
while ( $rows_spec = mysqli_fetch_array ( $res_spec ))
{
$spec_output .= " <tr> " ;
$spec_output .= " <td align= \" right \" class= \" VerdanaMediumBlack \" width= \" 10px \" > " ;
$spec_output .= " <input type= \" checkbox \" value= \" true \" name= \" " . $rows_spec [ 'item_spec' ] . " \" /> " ;
$spec_output .= " </td> " ;
$spec_output .= " <td class= \" VerdanaSmallBlack \" > " . $rows_spec [ 'item_spec' ] . " </td> " ;
$spec_output .= " </tr> " ;
} //end of spec loop
//end of spec table reached.
$spec_output .= " </table></td></tr> " ;
$subcat_output .= $spec_output ;
} //end of submaterial loop
//end of submaterial table reached.
$subcat_output .= " </table></td></tr> " ;
$output .= $subcat_output ;
//end of material table reached.
$output .= '</table></td></tr>' ;
} //end of material loop
echo $output ;
break ;
}
//SELECT cat_id, cat_name FROM tbl_categories WHERE cat_id IN (SELECT subcat FROM tbl_items WHERE item_name='".$Id."')";
//SELECT a.cat_id, a.cat_name FROM tbl_categories a, tbl_categories b WHERE b.cat_id=a.parent_id AND a.parent_id='30'
?>