98 lines
3.3 KiB
PHP
98 lines
3.3 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
//$company_profile_id = $_REQUEST['company_profile_id'];
|
|
//echo $company_profile_id;
|
|
//echo bndsfjfgj;
|
|
$name =$_POST['name'];
|
|
$code = $_POST['code'];
|
|
$address = $_POST['address'];
|
|
$contact_name = $_POST['contact_name'];
|
|
$phone= $_POST['phone'];
|
|
$email = $_POST['email'];
|
|
$website = $_POST['website'];
|
|
$logo=$_POST['logo'];
|
|
|
|
|
|
// echo hdfhfhds;
|
|
//$imagename=$_FILES['logo']['name'];
|
|
// $tempimgname=$_FILES['logo']['tmp_name'];
|
|
// move_uploaded_file($tempimgname,"images/$imagename");
|
|
// echo $imagename;
|
|
|
|
if(count($_FILES) > 0) {
|
|
// echo fjdfndjfndjf;
|
|
$_FILES['logo']['tmp_name'];
|
|
if(is_uploaded_file($_FILES['logo']['tmp_name']))
|
|
{
|
|
|
|
$info = pathinfo($_FILES['logo']['name']);
|
|
|
|
// $ext = pathinfo($info, PATHINFO_EXTENSION);
|
|
$imgData =addslashes(file_get_contents($_FILES['logo']['tmp_name']));
|
|
$imageProperties = getimageSize($_FILES['logo']['tmp_name']);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
$data = array();
|
|
$query = "";
|
|
$select_query = "select * from company_profile";
|
|
$result = mysqli_query($conn,$select_query);
|
|
$row = mysqli_fetch_array($result);
|
|
|
|
|
|
if($row>0){
|
|
|
|
// jgfjfhgjh
|
|
echo $logo.qqqq;
|
|
if(empty($imgData))
|
|
{
|
|
echo jgfjfhgjh;
|
|
//$query1 = "select logo,image_type from company_profile";
|
|
// $result1 = mysqli_query($conn,$query1);
|
|
// $row1 = mysqli_fetch_array($result1);
|
|
//echo $logo1=$row1['logo'];
|
|
//echo fjdghfjkghjk;
|
|
//$image_type1=$row1['image_type'];
|
|
$query = "update company_profile set company_name = '".addslashes($name)."', company_code = '".addslashes($code)."', address = '".addslashes($address)."'
|
|
, primary_contact_name='".addslashes($contact_name)."',primary_phone='".addslashes($phone)."', primary_email='".addslashes($email)."',
|
|
company_website='".addslashes($website)."',
|
|
modified_by = '".$_SESSION['user_id']."' where company_profile_id = 1";
|
|
// echo $query;
|
|
|
|
}
|
|
else{
|
|
echo jgfdjhhgh;
|
|
$query = "update company_profile set company_name = '".addslashes($name)."', company_code = '".addslashes($code)."', address = '".addslashes($address)."'
|
|
, primary_contact_name='".addslashes($contact_name)."',primary_phone='".addslashes($phone)."', primary_email='".addslashes($email)."',
|
|
company_website='".addslashes($website)."',logo='{$imgData}' ,image_type='{$imageProperties['mime']}',
|
|
modified_by = '".$_SESSION['user_id']."' where company_profile_id = 1";
|
|
echo $query;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
$query = "insert into company_profile set company_profile_id='1', company_name = '".addslashes($name)."', company_code = '".addslashes($code)."', address = '".addslashes($address)."'
|
|
, primary_contact_name='".addslashes($contact_name)."',primary_phone='".addslashes($phone)."', primary_email='".addslashes($email)."',
|
|
company_website='".addslashes($website)."',logo='{$imgData}' ,image_type='{$imageProperties['mime']}',
|
|
modified_by = '".$_SESSION['user_id']."' ";
|
|
}
|
|
// echo $query;
|
|
$data['query']=$query;
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
$data['status']=500;
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(data==null)
|
|
{
|
|
$data['status'] = 200;
|
|
//$data['message'] = "Data not found!";
|
|
}
|
|
echo json_encode($data);
|
|
?>
|