<?php
header("Content-type: text/html; charset=windows-1256");
session_start();


function mainContactInfo($customer_officeId,$contactinfo_id,$grid_color1,$grid_color2,$connection){


echo "<table border=0 width='1100px'><col width='30'><col width='30'><col width='100'><col width='100'><col width='100'>";
echo "<col width='150'><col width='80'><col width='80'><col width='80'>";
echo "<col width='100'><col width='100'><col width='100'><col width='30'>";
echo "<tr bgcolor='#D0D0D0'><td></td><td></td><td><span class='style127'>First Name<span class='style16'>*</span></span></td><td><span class='style127'>Father Name</span></td><td><span class='style127'>Last Name<span class='style16'>*</span></span></td>";
echo "<td><span class='style127'>Position<span class='style16'>*</span></span></td><td><span class='style127'>Phone #1<span class='style16'>*</span></span></td><td><span class='style127'>Phone #2</span></td><td><span class='style127'>Phone #3</span></td>";
echo "<td><span class='style127'>Email 1</span></td><td><span class='style127'>Email 2</span></td><td><span class='style127'>Card</span></td><td></td></tr>";


if($contactinfo_id != ''){
	$queryinfo = "select contact_firstname, contact_fathername, contact_lastname, contact_position, contact_phone1, 
					contact_phone2, contact_phone3, contact_email1, contact_email2, contact_photo ".
				" from CustomerContactInfo where contactinfo_id=$contactinfo_id";
	$resinfo = mysql_query($queryinfo,$connection);
	$rwinfo = mysql_fetch_row($resinfo);
	$txtctfirstname = $rwinfo[0];
	$txtctfathername = $rwinfo[1];
	$txtctlastname = $rwinfo[2];
	$txtctposition = $rwinfo[3];
	
	$txtctphone1 = $rwinfo[4];
	$txtctphone2 = $rwinfo[5];
	$txtctphone3 = $rwinfo[6];
	
	$txtctemail1 = $rwinfo[7];
	$txtctemail2 = $rwinfo[8];
	$photo = $rwinfo[9];
}
	
echo "<tr><td colspan='2'></td>";
echo "<td><input type='text' name='txtctfirstname' id='txtctfirstname' value='$txtctfirstname'></td>";
echo "<td><input type='text' name='txtctfathername' id='txtctfathername' value='$txtctfathername'></td>";
echo "<td><input type='text' name='txtctlastname' id='txtctlastname' value='$txtctlastname'></td>";
echo "<td><input type='text' name='txtctposition' id='txtctposition' value='$txtctposition'></td>";
echo "<td><input type='text' name='txtctphone1' id='txtctphone1' value='$txtctphone1'></td>";
echo "<td><input type='text' name='txtctphone2' id='txtctphone2' value='$txtctphone2'></td>";
echo "<td><input type='text' name='txtctphone3' id='txtctphone3' value='$txtctphone3'></td>";
echo "<td><input type='text' name='txtctemail1' id='txtctemail1' value='$txtctemail1'></td>";
echo "<td><input type='text' name='txtctemail2' id='txtctemail2' value='$txtctemail2'></td>";
echo "<td>";
if($contactinfo_id != '')
echo "<input type='file'  name='photo' id='photo' style='width:200px;cursor: pointer;font-size: 11px;' value='$photo' accept='image/jpeg,image/gif,image/png' >
		<input type='button' value='Upload' $style2 style='width:85px;cursor: pointer;font-size: 11px;' onclick=\"upload_picture('$contactinfo_id','$customer_officeId');\" > 
		<input type='button' value='Picture' $style2 onclick=\"show_picture('$contactinfo_id')\" style='width:85px;cursor: pointer;font-size: 11px;'>";
echo "</td>
<td><span class='style15'><img src='img/confirm.png'  onMouseOver=\"style.cursor='pointer'\" onclick=\"confirmMaininfo('$contactinfo_id','$customer_officeId');\" title='Delete Record'  ></span></td></tr>";

echo"<tr height='30'><td></td></tr>";

if($customer_officeId != ''){
	$queryinfo = "select contactinfo_id, contact_firstname, contact_fathername, contact_lastname, contact_position, contact_phone1, 
					contact_phone2, contact_phone3, contact_email1, contact_email2 ".
				" from CustomerContactInfo where customeroffice_id=$customer_officeId"; 
	$resinfo = mysql_query($queryinfo,$connection);
	while($rwinfo = mysql_fetch_row($resinfo)){
		$ct+=1;
		if($ct%2==0)
			$Color="style='background-color:".$grid_color1."'";
		else			
			$Color="style='background-color:".$grid_color2."'";	
		
		if( $contactinfo_id == $rwinfo[0]) {$Color = "style='background-color:#1e87a5;'";$classt='style111';}
		else $classt='style5';
		echo "<tr $Color><td><span class=$classt><img src='img/edit.png' style='width:18px;' onMouseOver=\"style.cursor='pointer'\" onclick=\"UpdateMaininfo('".$rwinfo[0]."')\" title='Edit Record'  ></span></td>";
		echo "<td><span class=$classt><img src='img/c_delete.png'  onMouseOver=\"style.cursor='pointer'\" onclick=\"deleteMaininfo('$rwinfo[0]');\" title='Delete Record'  ></span></td>";
		echo "<td><span class=$classt>$rwinfo[1]</span></td>";
		echo "<td><span class=$classt>$rwinfo[2]</span></td>";
		echo "<td><span class=$classt>$rwinfo[3]</span></td>";
		echo "<td><span class=$classt>$rwinfo[4]</span></td>";
		echo "<td><span class=$classt>$rwinfo[5]</span></td>";
		echo "<td><span class=$classt>$rwinfo[6]</span></td>";
		echo "<td><span class=$classt>$rwinfo[7]</span></td>";
		echo "<td><span class=$classt>$rwinfo[8]</span></td>";
		echo "<td><span class=$classt>$rwinfo[9]</span></td>";
		echo "<td colspan='2'><span class=$classt><input type='button' value='Show Card' $style2 onclick=\"show_picture('$rwinfo[0]')\" style='cursor: pointer;border-radius: 150px;line-height:20px ;font-weight: bold;font-size: 11px;'></span></td></tr>";

	}	

}
echo "</table>";
}

function branchContactInfo($customer_officeId2,$contactinfo_id2,$grid_color1,$grid_color2,$connection){
	echo "<table border=0 width='1100px'><col width='30'><col width='30'><col width='100'><col width='100'><col width='100'>";
echo "<col width='150'><col width='80'><col width='80'><col width='80'>";
echo "<col width='100'><col width='100'><col width='100'><col width='30'>";
echo "<tr bgcolor='#D0D0D0'><td></td><td></td><td><span class='style127'>First Name<span class='style16'>*</span></span></td><td><span class='style127'>Father Name</span></td><td><span class='style127'>Last Name<span class='style16'>*</span></span></td>";
echo "<td><span class='style127'>Position<span class='style16'>*</span></span></td><td><span class='style127'>Phone #1<span class='style16'>*</span></span></td><td><span class='style127'>Phone #2</span></td><td><span class='style127'>Phone #3</span></td>";
echo "<td><span class='style127'>Email 1</span></td><td><span class='style127'>Email 2</span></td><td><span class='style127'>Website</span></td><td></td></tr>";

if($contactinfo_id2 != ''){
	$queryinfo = "select contact_firstname, contact_fathername, contact_lastname, contact_position, contact_phone1, 
					contact_phone2, contact_phone3, contact_email1, contact_email2, contact_website ".
				" from CustomerContactInfo where contactinfo_id=$contactinfo_id2";
	$resinfo = mysql_query($queryinfo,$connection);
	$rwinfo = mysql_fetch_row($resinfo);
	$txtctfirstname2 = $rwinfo[0];
	$txtctfathername2 = $rwinfo[1];
	$txtctlastname2 = $rwinfo[2];
	$txtctposition2 = $rwinfo[3];
	
	$txtctphone12 = $rwinfo[4];
	$txtctphone22 = $rwinfo[5];
	$txtctphone32 = $rwinfo[6];
	
	$txtctemail12 = $rwinfo[7];
	$txtctemail22 = $rwinfo[8];
	$txtctwebsite2 = $rwinfo[9];
}
	
echo "<tr><td colspan='2'></td>";
echo "<td><input type='text' name='txtctfirstname2' id='txtctfirstname2' value='$txtctfirstname2'></td>";
echo "<td><input type='text' name='txtctfathername2' id='txtctfathername2' value='$txtctfathername2'></td>";
echo "<td><input type='text' name='txtctlastname2' id='txtctlastname2' value='$txtctlastname2'></td>";
echo "<td><input type='text' name='txtctposition2' id='txtctposition2' value='$txtctposition2'></td>";
echo "<td><input type='text' name='txtctphone12' id='txtctphone12' value='$txtctphone12'></td>";
echo "<td><input type='text' name='txtctphone22' id='txtctphone22' value='$txtctphone22'></td>";
echo "<td><input type='text' name='txtctphone32' id='txtctphone32' value='$txtctphone32'></td>";
echo "<td><input type='text' name='txtctemail12' id='txtctemail12' value='$txtctemail12'></td>";
echo "<td><input type='text' name='txtctemail22' id='txtctemail22' value='$txtctemail22'></td>";
echo "<td><input type='text' name='txtctwebsite2' id='txtctwebsite2' value='$txtctwebsite2'></td>
<td><span class='style15'><img src='img/confirm.png'  onMouseOver=\"style.cursor='pointer'\" onclick=\"confirmBranchinfo('$contactinfo_id2','$customer_officeId2');\" title='Delete Record'  ></span></td></tr>";

echo"<tr height='30'><td></td></tr>";

if($customer_officeId2 != ''){
	$queryinfo = "select contactinfo_id, contact_firstname, contact_fathername, contact_lastname, contact_position, contact_phone1, 
					contact_phone2, contact_phone3, contact_email1, contact_email2, contact_website ".
				" from CustomerContactInfo where customeroffice_id=$customer_officeId2"; 
	$resinfo = mysql_query($queryinfo,$connection);
	while($rwinfo = mysql_fetch_row($resinfo)){
		$ct+=1;
		if($ct%2==0)
			$Color="style='background-color:".$grid_color1."'";
		else			
			$Color="style='background-color:".$grid_color2."'";	
		
		if( $contactinfo_id2 == $rwinfo[0]) {$Color = "style='background-color:#1e87a5;'";$classt='style111';}
		else $classt='style5';
		echo "<tr $Color><td><span class=$classt><img src='img/edit.png' style='width:18px;' onMouseOver=\"style.cursor='pointer'\" onclick=\"UpdateBranchinfo('".$rwinfo[0]."')\" title='Edit Record'  ></span></td>";
		echo "<td><span class=$classt><img src='img/c_delete.png'  onMouseOver=\"style.cursor='pointer'\" onclick=\"deleteBranchinfo('$rwinfo[0]');\" title='Delete Record'  ></span></td>";
		echo "<td><span class=$classt>$rwinfo[1]</span></td>";
		echo "<td><span class=$classt>$rwinfo[2]</span></td>";
		echo "<td><span class=$classt>$rwinfo[3]</span></td>";
		echo "<td><span class=$classt>$rwinfo[4]</span></td>";
		echo "<td><span class=$classt>$rwinfo[5]</span></td>";
		echo "<td><span class=$classt>$rwinfo[6]</span></td>";
		echo "<td><span class=$classt>$rwinfo[7]</span></td>";
		echo "<td><span class=$classt>$rwinfo[8]</span></td>";
		echo "<td><span class=$classt>$rwinfo[9]</span></td>";
		echo "<td><span class=$classt>$rwinfo[10]</span></td></tr>";

	}	

}
echo "</table>";
}