<?php 
define('DOCUMENT_ROOT_CLASS','../../');
define('DOCUMENT_ROOT_INC_FOLDER','inc/');

$filepath = realpath(dirname(__FILE__));
if(!empty($_POST["action"]) and $_POST["action"] == "ajax_call_1"){
    require "../../inc/ajax_header.php";
    $commonFunctions->updateData('sys_erp_organaization'," WHERE id = '".$_POST['org_id']."' ", " erp_sys_org_name = '".$_POST['erp_sys_org_name']."', erp_sys_org_address='".$_POST['erp_sys_org_address']."', erp_sys_org_city='".$_POST['erp_sys_org_city']."' , erp_sys_org_province='".$_POST['erp_sys_org_province']."' , erp_sys_org_country='".$_POST['erp_sys_org_country']."' , erp_sys_org_zip_code='".$_POST['erp_sys_org_zip_code']."' , erp_sys_org_phone_work='".$_POST['erp_sys_org_phone_work']."', erp_sys_org_fax='".$_POST['erp_sys_org_fax']."', erp_sys_email_work='".$_POST['erp_sys_email_work']."', erp_sys_org_sm_page_linkedin='".$_POST['erp_sys_org_sm_page_linkedin']."', erp_sys_org_sm_page_twitter='".$_POST['erp_sys_org_sm_page_twitter']."', erp_sys_org_sm_page_facebook='".$_POST['erp_sys_org_sm_page_facebook']."', erp_sys_org_department='".$_POST['erp_sys_org_department']."', erp_sys_org_num_emp='".$_POST['erp_sys_org_num_emp']."', erp_sys_org_date_formation='".$_POST['erp_sys_org_date_formation']."', erp_sys_org_web='".$_POST['erp_sys_org_web']."', erp_sys_org_date_formation='".$_POST['erp_sys_org_date_formation']."'",'');
    echo "organization.php?state=list";
    exit();
}
if(!empty($_POST["action"]) and $_POST["action"] == "ajax_call"){
    require "../../inc/ajax_header.php";
    $country_id = $_POST["country_id"];
    $getData = $commonFunctions->getData('sys_erp_adm_countries_states'," WHERE country_id = '".$country_id."' and active = 1 ");
    $html = "";
    foreach ($getData as $rw) {
        $html .= "<option value='".$rw['rowid']."'>".$rw['label']."</option>";
    }
    echo json_encode(array("option"=>$html));
    exit();
}
if(!empty($_GET["action"]) and $_GET["action"] == "ajax_call1"){
    require "../../inc/ajax_header.php";
    $country_id = $_GET["country_id"];
    $state_id = $_GET["state_id"];
    $keyword = $_GET["keyword"]; 
    $getData = $commonFunctions->getData('sys_erp_adm_countries_states_cities'," WHERE country_id = '".$country_id."' and state_id = '".$state_id."' and name LIKE '%".$keyword."%' ");
    $html = "";
    $skillData = array(); 
    foreach ($getData as $rw) {
        $data['id'] = $rw['name']; 
        $data['value'] = $rw['name']; 
        array_push($skillData, $data); 
    } 
    echo json_encode($skillData);
    exit();
}
if(!empty($_POST['action']) and @$_POST['action'] == "profile"){
    $column = $fileName = "";
    if(!empty($_FILES["erp_sys_org_logo"])){
        $target_dir = "../../uploads/admin-setting/company/";
        $target_file = $target_dir . basename($_FILES["erp_sys_org_logo"]["name"]);
        $uploadOk = 1;
        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
        @getimagesize($_FILES["erp_sys_org_logo"]["tmp_name"]);
        if(@move_uploaded_file($_FILES["erp_sys_org_logo"]["tmp_name"], $target_file)){
            $column = " erp_sys_org_logo";
            $fileName = " erp_sys_org_logo = '".$_FILES["erp_sys_org_logo"]["name"]."' ";
            $commonFunctions->updateData('sys_erp_organaization'," WHERE id = '".$_POST['org_id']."' ", $fileName ,'organization.php?state=list');
        }
    }else{
        Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Organization profile picture not saved!</div>');
        echo "<script>location.href='organization.php?state=list';</script>";
    }
    exit();
}

require "../../inc/header.php";
$msg = Session::get('msg');
Session::set("msg", NULL);
if(!empty($_POST)){
    $error_ = 0;
    if(empty($_POST['erp_sys_org_name'])){
        Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter organization name!</div>');
    }else{
        $cntA = $commonFunctions->getRowData('sys_erp_organaization',' WHERE id NOT IN('.$_POST['org_id'].') and erp_sys_org_name = "'.$_POST['erp_sys_org_name'].'" ');
        if(@count($cntA) > 1){
           $error_ = 1;
           Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> organization name already exists !</div>');
        }
    }

    if(!empty($_POST['erp_sys_org_name']) and $error_ == 0){
        $cntB = $commonFunctions->getRecordCount('sys_erp_organaization','');
 
        if($cntB == 0){
            $column = $fileName = "";
            if(!empty($_FILES["erp_sys_org_logo"])){
                $target_dir = "../../uploads/admin-setting/company/";
                $target_file = $target_dir.basename($_FILES["erp_sys_org_logo"]["name"]);
                $uploadOk = 1;
                $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
                @getimagesize($_FILES["erp_sys_org_logo"]["tmp_name"]);
                if(move_uploaded_file($_FILES["erp_sys_org_logo"]["tmp_name"], $target_file)){
                    $column = " erp_sys_org_logo";
                    $fileName = $_FILES["erp_sys_org_logo"]["name"];
                }
            }
            $commonFunctions->addData('sys_erp_organaization'," (erp_sys_org_name,erp_sys_org_address,erp_sys_org_city,erp_sys_org_province,erp_sys_org_country,erp_sys_org_zip_code,erp_sys_org_phone_work,erp_sys_org_fax,erp_sys_email_work,erp_sys_org_sm_page_linkedin,erp_sys_org_sm_page_twitter,erp_sys_org_sm_page_facebook,erp_sys_org_sm_page_instagram,erp_sys_org_id_msngr_whatsapp,erp_sys_org_department,erp_sys_org_cr_num,erp_sys_org_cr_address,erp_sys_org_cr_city,erp_sys_org_cr_province,erp_sys_org_cr_country,erp_sys_org_cr_zip_code,erp_sys_org_tax_id_1,erp_sys_org_tax_id_2,erp_sys_org_inport_id,erp_sys_org_export_id,".$column.") VALUES ('".$_POST['erp_sys_org_name']."','".$_POST['erp_sys_org_address']."','".$_POST['erp_sys_org_city']."','".$_POST['erp_sys_org_province']."','".$_POST['erp_sys_org_country']."','".$_POST['erp_sys_org_zip_code']."','".$_POST['erp_sys_org_phone_work']."','".$_POST['erp_sys_org_fax']."','".$_POST['erp_sys_email_work']."','".$_POST['erp_sys_org_sm_page_linkedin']."','".$_POST['erp_sys_org_sm_page_twitter']."','".$_POST['erp_sys_org_sm_page_facebook']."','".$_POST['erp_sys_org_sm_page_instagram']."','".$_POST['erp_sys_org_id_msngr_whatsapp']."','".$_POST['erp_sys_org_department']."','".$_POST['erp_sys_org_cr_num']."','".$_POST['erp_sys_org_cr_address']."','".$_POST['erp_sys_org_cr_city']."','".$_POST['erp_sys_org_cr_province']."','".$_POST['erp_sys_org_cr_country']."','".$_POST['erp_sys_org_cr_zip_code']."','".$_POST['erp_sys_org_tax_id_1']."','".$_POST['erp_sys_org_tax_id_2']."','".$_POST['erp_sys_org_inport_id']."','".$_POST['erp_sys_org_export_id']."','".$fileName."' ) ",'organization.php?state=list');
        }
        if($cntB == 1){

            if(!empty($_FILES["erp_sys_org_logo"])){
                $target_dir = "../../uploads/admin-setting/company/";
                $target_file = $target_dir . basename($_FILES["erp_sys_org_logo"]["name"]);
                $uploadOk = 1;
                $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
                @getimagesize($_FILES["erp_sys_org_logo"]["tmp_name"]);
                if(@move_uploaded_file($_FILES["erp_sys_org_logo"]["tmp_name"], $target_file)){
                    $column = " erp_sys_org_logo";
                    $fileName = " erp_sys_org_logo = '".$_FILES["erp_sys_org_logo"]["name"]."' ";
                    $commonFunctions->updateData('sys_erp_organaization'," WHERE id = '".$_POST['org_id']."' ", $fileName ,'');
                }
            }

            $commonFunctions->updateData('sys_erp_organaization'," WHERE id = '".$_POST['org_id']."' ", " erp_sys_org_name = '".$_POST['erp_sys_org_name']."', erp_sys_org_address='".$_POST['erp_sys_org_address']."', erp_sys_org_city='".$_POST['erp_sys_org_city']."' , erp_sys_org_province='".$_POST['erp_sys_org_province']."' , erp_sys_org_country='".$_POST['erp_sys_org_country']."' , erp_sys_org_zip_code='".$_POST['erp_sys_org_zip_code']."' , erp_sys_org_phone_work='".$_POST['erp_sys_org_phone_work']."', erp_sys_org_fax='".$_POST['erp_sys_org_fax']."', erp_sys_email_work='".$_POST['erp_sys_email_work']."', erp_sys_org_sm_page_linkedin='".$_POST['erp_sys_org_sm_page_linkedin']."', erp_sys_org_sm_page_twitter='".$_POST['erp_sys_org_sm_page_twitter']."', erp_sys_org_sm_page_facebook='".$_POST['erp_sys_org_sm_page_facebook']."', erp_sys_org_sm_page_instagram='".$_POST['erp_sys_org_sm_page_instagram']."', erp_sys_org_id_msngr_whatsapp='".$_POST['erp_sys_org_id_msngr_whatsapp']."', erp_sys_org_department='".$_POST['erp_sys_org_department']."', erp_sys_org_cr_num='".$_POST['erp_sys_org_cr_num']."', erp_sys_org_cr_address='".$_POST['erp_sys_org_cr_address']."', erp_sys_org_cr_city='".$_POST['erp_sys_org_cr_city']."', erp_sys_org_cr_province='".$_POST['erp_sys_org_cr_province']."', erp_sys_org_cr_country='".$_POST['erp_sys_org_cr_country']."', erp_sys_org_cr_zip_code='".$_POST['erp_sys_org_cr_zip_code']."', erp_sys_org_tax_id_1='".$_POST['erp_sys_org_tax_id_1']."', erp_sys_org_tax_id_2='".$_POST['erp_sys_org_tax_id_2']."', erp_sys_org_inport_id='".$_POST['erp_sys_org_inport_id']."', erp_sys_org_export_id='".$_POST['erp_sys_org_export_id']."'",'organization.php?state=list');
        }
    }else{
        echo "<script>location.href='organization.php?state=form';</script>";
    }

}
$cntB = $commonFunctions->getRecordCount('sys_erp_organaization','');
if($cntB == 1){
    $editData = $commonFunctions->getRowData('sys_erp_organaization'," WHERE id != '0' ");
}
?>    
    
        
    <!-- Page-Title -->
    <div class="row">
        <div class="col-sm-12">
            <div class="page-title-box">
                <div class="row">
                    <div class="col">
                        <h4 class="page-title"><?php echo ($cntB == 0)?" Organization Details ":@$editData['erp_sys_org_name']; ?></h4>
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Settings</a></li>
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Organization Details</a></li>
                            <li class="breadcrumb-item"><a href="javascript:void(0);"><?php echo ($cntB == 0)?" Organization ":@$editData['erp_sys_org_name']; ?></a></li>
                        </ol>
                    </div><!--end col-->
                    <!-- <div class="col-auto align-self-center">
                        <a href="#" class="btn btn-sm btn-outline-primary" id="Dash_Date">
                            <span class="day-name" id="Day_Name">Today:</span>&nbsp;
                            <span class="" id="Select_date">Jan 11</span>
                            <i data-feather="calendar" class="align-self-center icon-xs ml-1"></i>
                        </a>
                        <a href="#" class="btn btn-sm btn-outline-primary">
                            <i data-feather="download" class="align-self-center icon-xs"></i>
                        </a>
                    </div> --><!--end col-->  
                </div><!--end row-->                                                              
            </div><!--end page-title-box-->
        </div><!--end col-->
    </div><!--end row-->
    <!-- end page title end breadcrumb -->
    <div class="row">
        <div class="col-md-12">
            <?php if($cntB < 1): ?>
            <div class="card">
            <?php endif; ?>
                <?php if($cntB < 1): ?>
                <div class="card-header">
                    <h4 class="card-title">
                        <div class="form-row">
                            <div class="form-group searchForm col-md-6">
                                <?php 
                                $cntB = $commonFunctions->getRecordCount('sys_erp_organaization','');
                                if($cntB == 0){ ?>
                                    <a class="btn btn-sm btn-soft-primary" href="organization.php?state=form" role="button" style="float: left;"><i class="fas fa-plus mr-2"></i> Add New Organization Details</a>
                                <?php } ?>
                            </div>
                            <!-- <div class="form-group searchForm col-md-6">
                                <?php if(empty($_GET['state']) OR (!empty($_GET['state']) and $_GET['state'] == "list")): ?>
                                <form action="" id="searchForm" method="GET">
                                    <div class="form-row">
                                        <div class="form-group searchForm col-md-8">
                                            <input type="text" name="search" id="search" placeholder="Search" class="form-control" value="<?php echo @$_GET['search']; ?>">
                                            <input type="hidden" name="state" value="<?php echo @$_GET['state']; ?>">
                                            <input type="hidden" name="page" value="<?php echo @$_GET['page']; ?>">
                                        </div>
                                        <div class="form-group searchForm col-md-4">
                                            <button type="submit" id="searchbtn" class="btn btn-primary"> <i class="fa fa-search"></i> Search</button>
                                            <button type="button" id="clearbtn" class="btn btn-danger"> <i class="fa fa-trash"></i> Clear</button>
                                        </div>
                                    </div>
                                </form>
                                <?php endif; ?>
                            </div> -->
                        </div>
                    </h4>
                </div>
                <?php endif; ?>
                <?php echo !empty($msg)?$msg:''; ?>        
                <?php echo !empty($msg1)?$msg1:''; ?>        
                    <?php if($cntB < 1): ?>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="main-card mb-3 ">
                                <!-- <div class="card-body"> -->
                                        <form enctype="multipart/form-data" action="organization.php?state=form&action=add" method="post" name="formsoc" autocomplete="off">      
                                            <div class="form-row">
                                                <input type="hidden" name="action" value="add">
                                                <input type="hidden" name="org_id" value="<?php echo !empty(@$editData['id'])?$editData['id']:0;?>">
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_name" class="">Company Name <span class="error">*</span></label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_name" id="erp_sys_org_name" value="<?php echo @$editData['erp_sys_org_name'];?>" autofocus="autofocus" class="form-control" placeholder="Company Name" required="">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_address" class="">Company Address</label>
                                                    <textarea name="erp_sys_org_address" class="form-control" placeholder="Company Address"><?php echo @$editData['erp_sys_org_address'];?></textarea>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_country" class=""> Company Country </label>
                                                    <?php $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 '); ?>
                                                    <select name="erp_sys_org_country" id="erp_sys_org_country" class="select2 form-control" >
                                                        <option value="0">Select Company Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (@$editData['erp_sys_org_country'] == $rw['rowid'])?'selected':'';?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>     
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_province" class="">Company State / Province</label>
                                                    <?php $stateData = $commonFunctions->getData('sys_erp_adm_countries_states',' WHERE active = 1 '); ?>
                                                    <select name="erp_sys_org_province" id="erp_sys_org_province" class="select2 form-control" >
                                                        <option value="0">Select Company State / Province</option>
                                                        <?php foreach ($stateData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (@$editData['erp_sys_org_province'] == $rw['rowid'])?'selected':'';?> ><?php echo $rw['label']."(".$rw['region_code'].")"; ?></option>     
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_city" class="">Company City</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_city" id="erp_sys_org_city" value="<?php echo @$editData['erp_sys_org_city'];?>" autofocus="autofocus" class="form-control" placeholder="Company City">
                                                </div>

                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_zip_code" class="">Company Zip Code</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_zip_code" id="erp_sys_org_zip_code" value="<?php echo @$editData['erp_sys_org_zip_code'];?>" autofocus="autofocus" class="form-control" placeholder="Company Zip Code">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_branch" class="">Company Branch</label>
                                                    <select name="erp_sys_org_branch" class="form-control">
                                                        <option value="0"> Select </option>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_phone_work" class="">Work Phone</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_phone_work" id="erp_sys_org_phone_work" value="<?php echo @$editData['erp_sys_org_phone_work'];?>" autofocus="autofocus" class="form-control" placeholder="Work Phone">
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_fax" class="">Work Fax</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_fax" id="erp_sys_org_fax" value="<?php echo @$editData['erp_sys_org_fax'];?>" autofocus="autofocus" class="form-control" placeholder="Work Fax">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_email_work" class="">Work eMail</label>
                                                    <input type="text" maxlength="128" name="erp_sys_email_work" id="erp_sys_email_work" value="<?php echo @$editData['erp_sys_email_work'];?>" autofocus="autofocus" class="form-control" placeholder="Work eMail">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_sm_page_linkedin" class="">linkedIn</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_sm_page_linkedin" id="erp_sys_org_sm_page_linkedin" value="<?php echo @$editData['erp_sys_org_sm_page_linkedin'];?>" autofocus="autofocus" class="form-control" placeholder="linkedIn">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_sm_page_twitter" class="">Twitter</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_sm_page_twitter" id="erp_sys_org_sm_page_twitter" value="<?php echo @$editData['erp_sys_org_sm_page_twitter'];?>" autofocus="autofocus" class="form-control" placeholder="Twitter">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_sm_page_facebook" class="">Facebook</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_sm_page_facebook" id="erp_sys_org_sm_page_facebook" value="<?php echo @$editData['erp_sys_org_sm_page_facebook'];?>" autofocus="autofocus" class="form-control" placeholder="Facebook">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_sm_page_instagram" class="">Instagram</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_sm_page_instagram" id="erp_sys_org_sm_page_instagram" value="<?php echo @$editData['erp_sys_org_sm_page_instagram'];?>" autofocus="autofocus" class="form-control" placeholder="Facebook">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_id_msngr_whatsapp" class="">Business Whatsapp</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_id_msngr_whatsapp" id="erp_sys_org_id_msngr_whatsapp" value="<?php echo @$editData['erp_sys_org_id_msngr_whatsapp'];?>" autofocus="autofocus" class="form-control" placeholder="Business Whatsapp">
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_department" class="">Departnemt ( Company )</label>
                                                    <?php $departmentData = $commonFunctions->getData('sys_erp_org_department',' '); ?>
                                                    <select name="erp_sys_org_department" id="erp_sys_org_department" class="select2 form-control" >
                                                        <option value="0">Select Departnemt ( Company )</option>
                                                        <?php foreach ($departmentData as $rw) { ?>
                                                            <option value="<?php echo $rw['id'];?>" <?php echo (@$editData['erp_sys_org_department'] == $rw['id'])?'selected':'';?> ><?php echo $rw['erp_sys_org_dprtmt_ops']; ?></option>     
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_cr_num" class="">Company Commercial Registration No</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_cr_num" id="erp_sys_org_cr_num" value="<?php echo @$editData['erp_sys_org_cr_num'];?>" autofocus="autofocus" class="form-control" placeholder="Company Commercial Registration No">
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_cr_address" class="">Company Regiatration Address</label>
                                                    <textarea name="erp_sys_org_cr_address" class="form-control" placeholder="Company Regiatration Address"><?php echo @$editData['erp_sys_org_cr_address'];?></textarea>
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_cr_city" class="">Company Regiatration City</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_cr_city" id="erp_sys_org_cr_city" value="<?php echo @$editData['erp_sys_org_cr_city'];?>" autofocus="autofocus" class="form-control" placeholder="Company Regiatration City">
                                                </div>

                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_cr_province" class="">Company Regiatration Province</label>
                                                    <?php $stateData = $commonFunctions->getData('sys_erp_adm_countries_states',' WHERE active = 1 '); ?>
                                                    <select name="erp_sys_org_cr_province" id="erp_sys_org_cr_province" class="select2 form-control" >
                                                        <option value="0">Select Company State / Province</option>
                                                        <?php foreach ($stateData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (@$editData['erp_sys_org_cr_province'] == $rw['rowid'])?'selected':'';?> ><?php echo $rw['label']."(".$rw['region_code'].")"; ?></option>     
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_cr_country" class="">Company Regiatration Country</label>
                                                    <?php $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 '); ?>
                                                    <select name="erp_sys_org_cr_country" id="erp_sys_org_cr_country" class="select2 form-control" >
                                                        <option value="0">Select Company Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (@$editData['erp_sys_org_cr_country'] == $rw['rowid'])?'selected':'';?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>     
                                                        <?php } ?>
                                                    </select>
                                                </div>

                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_cr_zip_code" class="">Company Regiatration Zip Code</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_cr_zip_code" id="erp_sys_org_cr_zip_code" value="<?php echo @$editData['erp_sys_org_cr_zip_code'];?>" autofocus="autofocus" class="form-control" placeholder="Company Regiatration Zip Code">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_tax_id_1" class="">Company TAX ID 1</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_tax_id_1" id="erp_sys_org_tax_id_1" value="<?php echo @$editData['erp_sys_org_tax_id_1'];?>" autofocus="autofocus" class="form-control" placeholder="Company TAX ID 1">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_tax_id_2" class="">Company TAX ID 2</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_tax_id_2" id="erp_sys_org_tax_id_2" value="<?php echo @$editData['erp_sys_org_tax_id_2'];?>" autofocus="autofocus" class="form-control" placeholder="Company TAX ID 2">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_inport_id" class="">Company Import ID</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_inport_id" id="erp_sys_org_inport_id" value="<?php echo @$editData['erp_sys_org_inport_id'];?>" autofocus="autofocus" class="form-control" placeholder="Company Import ID">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_export_id" class="">Company Export ID</label>
                                                    <input type="text" maxlength="128" name="erp_sys_org_export_id" id="erp_sys_org_export_id" value="<?php echo @$editData['erp_sys_org_export_id'];?>" autofocus="autofocus" class="form-control" placeholder="Company Export ID">
                                                </div>
                                                <div class="position-relative form-group col-md-4">
                                                    <label for="erp_sys_org_logo" class=""> Organization Logo (Avatar) </label>
                                                    <input type="file" name="erp_sys_org_logo" >
                                                </div>

                                                <div class="position-relative form-group col-md-12">
                                                    <button type="submit" class="btn btn-success">Save</button>
                                                    <a href="organization.php?state=list"><button type="button" class="btn btn-danger">Back to Organization List</button></a>
                                                </div>
                                            </div>
                                        </form>
                                <!-- </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>
                    <?php if($cntB >= 1 and @$_GET['action'] != "edit"): ?>
                <div class="card">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="dastone-profile">
                                    <div class="row">
                                        <div class="col-lg-7 align-self-center mb-3 mb-lg-0">
                                            <div class="dastone-profile-main">
                                                <div class="col-lg-6 align-self-center mb-3 mb-lg-0">
                                                    <img src="../../uploads/admin-setting/company/<?php echo (@$editData['erp_sys_org_logo'])?$editData['erp_sys_org_logo']:'default-img.jpg';?>" alt="" height="110" class="thumb-lx rounded" style='max-width:300px;'>
                                                </div>
                                                <div class="col-lg-6 align-self-center mb-3 mb-lg-0">
                                                    <h5 class="dastone-user-name"><?php echo $editData['erp_sys_org_name'];?></h5>
                                                    <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $editData['erp_sys_org_address'];?></p>
                                                    <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $editData['erp_sys_org_city'];?>, P.O.Box - <?php echo $editData['erp_sys_org_zip_code'];?></p>
                                                    <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $commonFunctions->getName(@$editData['erp_sys_org_country'],'sys_erp_adm_countries','label','rowid');?></p>
                                                </div>
                                            </div>                                                
                                        </div><!--end col-->
                                        
                                        <div class="col-lg-5 ml-auto align-self-center">
                                            <ul class="list-unstyled personal-detail mb-0">
                                                <li class="mt-2"><i class="las la-phone mr-2 text-secondary font-22 align-middle"></i> <b> Phone </b> :  <?php echo $editData['erp_sys_org_phone_work'];?></li>
                                                <li class="mt-2"><i class="las la-mobile mr-2 text-secondary font-22 align-middle"></i> <b> Mobile </b> :  0</li>
                                                <li class="mt-2"><i class="las la-envelope text-secondary font-22 align-middle mr-2"></i> <b> Email </b> :   <a href="mailto:<?php echo $editData['erp_sys_email_work'];?>"><?php echo $editData['erp_sys_email_work'];?></a></li>                                                  
                                            </ul>                                               
                                        </div><!--end col-->
                                        
                                    </div><!--end row-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="pb-4">
                    <ul class="nav-border nav nav-pills mb-0" id="pills-tab" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" id="Profile_Project_tab" data-toggle="pill" href="#User_Profile">Organization Profile</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" id="Profile_Project_tab" data-toggle="pill" href="#Branches_Warehouse">Branches &amp; Warehouse</a>
                        </li>
                    </ul>        
                </div>
                <div class="row">
                    <div class="col-12">
                        <div class="tab-content" id="pills-tabContent">
                            
                            <div class="tab-pane fade show active" id="User_Profile" role="tabpanel" aria-labelledby="settings_detail_tab">
                                <div class="row">
                                    
                                    <!-- Organization Information Card - Start --->
                                    <div class="col-lg-6 col-xl-6">
                                        <div class="card">
                                            <div class="card-header">
                                                <div class="row align-items-center">
                                                    <div class="col-11">                      
                                                        <h4 class="card-title text-left">Organization Information</h4>                      
                                                    </div><!--end col-->
                                                    <div class="col-1">                      
                                                        <a href="organization.php?state=form&action=edit"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a>              
                                                    </div><!--end col-->                                                       
                                                </div>  <!--end row-->                                  
                                            </div><!--end card-header-->
                                            <div class="card-body">                                                                          
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Organization Name</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_name"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Industry / Business</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $commonFunctions->getName(@$editData['erp_sys_org_department'],'sys_erp_org_department','erp_sys_org_dprtmt_ops','erp_sys_org_dprtmt_id');?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Number of Empolyees</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title">  <?php echo $editData["erp_sys_org_num_emp"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Date of Formation</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_date_formation"];?> </h5>
                                                    </div>
                                                </div>                                          
                                            </div>                                            
                                        </div>
                                        <!-- Organization Information Card - End --->
                                        <!-- Organization Address Card - Start --->
                                        <div class="card">
                                            <div class="card-header">
                                                <div class="row align-items-center">
                                                    <div class="col-11">                      
                                                        <h4 class="card-title text-left">Office Address </h4>                      
                                                    </div><!--end col-->
                                                    <div class="col-1">                      
                                                        <a href="organization.php?state=form&action=edit"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a>              
                                                    </div><!--end col-->                                                       
                                                </div>  <!--end row-->                                  
                                            </div><!--end card-header-->
                                            <div class="card-body">                                                                          
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Address</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_address"];?></p> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">City</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_city"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">State / Province</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $commonFunctions->getName(@$editData['erp_sys_org_province'],'sys_erp_adm_countries_states','label','rowid');?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Zip / Pin / PO Box</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_zip_code"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Country</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $commonFunctions->getName(@$editData['erp_sys_org_country'],'sys_erp_adm_countries','label','rowid');?></h5>
                                                    </div>
                                                </div>                                                    
                                            </div><!--end card-body-->
                                        </div><!--end card-->
                                        <!-- Organization Address Card - End --->
                                    </div> <!--end col--> 
                                    <!-- Contact Information Personal  Card - End --->

                                    <!-- Contact Information Card Official - Start --->
                                    <div class="col-lg-6 col-xl-6">
                                        <div class="card">
                                            <div class="card-header">
                                                <div class="row align-items-center">
                                                    <div class="col-11">                      
                                                        <h4 class="card-title text-left">Contact Information<label class="col-xl-3 col-lg-3 mb-lg-0 align-self-center">(Organization)</label></h4>                      
                                                    </div><!--end col-->
                                                    <div class="col-1">                      
                                                        <a href="organization.php?state=form&action=edit"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a>              
                                                    </div><!--end col-->                                                       
                                                </div>  <!--end row-->                                  
                                            </div><!--end card-header-->
                                            <div class="card-body">                                                                          
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Phone </label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_phone_work"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Fax</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_fax"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Toll Free</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Email Address</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_email_work"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Website / URL</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_web"];?> </h5>
                                                    </div>
                                                </div>
                                            </div><!--end card-body-->
                                        </div><!--end card-->
                                        <!-- Organization Social Media - Start --->
                                        <div class="card">
                                            <div class="card-header">
                                                <div class="row align-items-center">
                                                    <div class="col-11">                      
                                                        <h4 class="card-title text-left">Social Media </h4>                      
                                                    </div><!--end col-->
                                                    <div class="col-1">                      
                                                        <a href="organization.php?state=form&action=edit"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a>              
                                                    </div><!--end col-->                                                       
                                                </div>  <!--end row-->                                  
                                            </div><!--end card-header-->
                                            <div class="card-body">                                                                          
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Linkedin</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_sm_page_linkedin"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Twitter</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_sm_page_twitter"];?> </h5>
                                                    </div>
                                                </div>
                                                <div class="form-group row">                                         
                                                    <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Facebook</label>
                                                    <div class="col-lg-9 col-xl-8">
                                                        <h5 class="card-title"> <?php echo $editData["erp_sys_org_sm_page_facebook"];?> </h5>
                                                    </div>
                                                </div>                                                    
                                            </div><!--end card-body-->
                                        </div><!--end card-->
                                        <!-- Organization Social Media - End --->
                                    </div> <!-- end col -->
                                    <!-- Contact Information Official Card - End --->
                                                                          
                                </div><!--end row-->
                            </div>

                            <div class="tab-pane fade" id="Branches_Warehouse" role="tabpanel" aria-labelledby="settings_detail_tab">
                                <div class="row">                        
                                    <div class="col-lg-12">
                                        <div class="card">
                                            <div class="card-header">
                                                <div class="row align-items-center">
                                                    <div class="col-11">                
                                                        <h4 class="card-title text-left">Branches & Warehouse</h4>                      
                                                    </div><!--end col-->
                                                </div>
                                            </div>
                                            <style type="text/css">
                                                tr {cursor: pointer;}
                                            </style>
                                            <div class="card-body">
                                                <table style="width: 100% !important;" class="table datatable_t table-hover table-striped table-bordered">
                                                    <thead>
                                                        <tr>
                                                            <th class="text-center">SR No.</th>
                                                            <th class="text-center">Warehouse Name</th>
                                                            <th class="text-center">Warehouse Ref</th>
                                                            <th class="text-center">Address</th>
                                                            <th class="text-center">Zip / Pin Code</th>
                                                            <th class="text-center">City</th>
                                                            <th class="text-center">Country</th>
                                                            <!-- <th class="text-center">Status</th> -->
                                                            <!-- <th class="text-center">Action</th> -->
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php $where = ""; 
                                                        $productData = $commonFunctions->getData('invty_wrhus',$where); 
                                                        foreach ($productData as $row) { 
                                                            $i++;?>
                                                            <tr onclick="redirect_1('../../product-services/warehouse/warehouse.php?state=edit&warehouse_id=<?php echo $row['id'];?>')" >
                                                            <th class="text-center text-primary" ><?php echo $row['reference_number'];?></th>
                                                            <th class="text-center text-primary"><?php echo $row['short_name_location'];?></th>
                                                            <th class="text-center"><?php echo $row['description'];?></th>
                                                            <th class="text-center"><?php echo $row['address'];?></th>
                                                            <th class="text-center"><?php echo $row['zip_code'];?></th>
                                                            <th class="text-center"><?php echo $row['city'];?></th>
                                                            <th class="text-center">
                                                                <?php echo $commonFunctions->getName(@$row['country_id'],'sys_erp_adm_countries','label','rowid');?>
                                                            </th>
                                                            <!-- <th>
                                                                <?php
                                                                    $flag = '';
                                                                    $flag_state = 0;
                                                                    if($row['status'] == 0){
                                                                        $flag = 'checked';
                                                                        $flag_state = 1;
                                                                    }
                                                                    $url = 'warehouse.php?state=list&warehouse_id='.$row['id'].'&flag='.$flag_state;
                                                                    echo '<div class="custom-control custom-switch switch-primary">
                                                                        <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                                        <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                                    </div>';
                                                                ?>
                                                            </th> -->
                                                        </tr>
                                                        <?php } ?>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div><!--end card--> 
                                    </div> <!--end col--> 
                
                                </div> <!-- end row -->
                                <!-- end page title end breadcrumb -->
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>

                <?php if($cntB >= 1 and @$_GET['action'] == "edit"): ?>
                <form enctype="multipart/form-data" action="javascript:void(0);" method="post" name="formsoc" autocomplete="off" id="editData">      
                    <input type="hidden" name="org_id" value="<?php echo !empty(@$editData['id'])?$editData['id']:0;?>">
                    <div class="card">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="dastone-profile">
                                        <div class="row">
                                            <div class="col-lg-7 align-self-center mb-3 mb-lg-0">
                                                <div class="dastone-profile-main">
                                                    <div class="col-lg-6 align-self-center mb-3 mb-lg-0">
                                                        <img src="../../uploads/admin-setting/company/<?php echo (@$editData['erp_sys_org_logo'])?$editData['erp_sys_org_logo']:'default-img.jpg';?>" alt="" height="110" class="thumb-lx rounded" style='max-width:300px;'>
                                                    </div>
                                                    <div class="col-lg-6 align-self-center mb-3 mb-lg-0">
                                                        <h5 class="dastone-user-name"><?php echo $editData['erp_sys_org_name'];?></h5>
                                                        <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $editData['erp_sys_org_address'];?></p>
                                                        <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $editData['erp_sys_org_city'];?>, P.O.Box - <?php echo $editData['erp_sys_org_province'];?></p>
                                                        <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i><?php echo $commonFunctions->getName(@$editData['erp_sys_org_country'],'sys_erp_adm_countries','label','rowid');?></p>
                                                    </div>
                                                </div>                                                
                                            </div><!--end col-->
                                            
                                            <div class="col-lg-5 ml-auto align-self-center">
                                                <ul class="list-unstyled personal-detail mb-0">
                                                    <li class="mt-2"><i class="las la-phone mr-2 text-secondary font-22 align-middle"></i> <b> Phone </b> :  <?php echo $editData['erp_sys_org_phone_work'];?></li>
                                                    <li class="mt-2"><i class="las la-mobile mr-2 text-secondary font-22 align-middle"></i> <b> Mobile </b> :  0</li>
                                                    <li class="mt-2"><i class="las la-envelope text-secondary font-22 align-middle mr-2"></i> <b> Email </b> :   <a href="mailto:<?php echo $editData['erp_sys_email_work'];?>"><?php echo $editData['erp_sys_email_work'];?></a></li>                                                  
                                                </ul>                                               
                                            </div><!--end col-->
                                            
                                        </div><!--end row-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="pb-4">
                        <ul class="nav-border nav nav-pills mb-0" id="pills-tab" role="tablist">
                            <li class="nav-item">
                                <a class="nav-link active" id="Profile_Project_tab" data-toggle="pill" href="#User_Profile">Organization Profile</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" id="Profile_Project_tab" data-toggle="pill" href="#Branches_Warehouse">Branches &amp; Warehouse</a>
                            </li>
                        </ul>        
                    </div>
                    <div class="row">
                        <div class="col-12">
                            <div class="tab-content" id="pills-tabContent">
                                
                                <div class="tab-pane fade show active" id="User_Profile" role="tabpanel" aria-labelledby="settings_detail_tab">
                                    <div class="row">
                                        
                                        <!-- Organization Information Card - Start --->
                                        <div class="col-lg-6 col-xl-6">
                                            <div class="card">
                                                <div class="card-header">
                                                    <div class="row align-items-center">
                                                        <div class="col-11">                      
                                                            <h4 class="card-title text-left">Organization Information</h4>                      
                                                        </div><!--end col-->
                                                        <div class="col-1">                      
                                                            <a href="javascript:void(0);"><button type="button" class="text-right btn btn-sm btn-success waves-effect waves-light save_org_data">Save</button></a>
                                                        </div><!--end col-->                                                       
                                                    </div>  <!--end row-->                                  
                                                </div><!--end card-header-->
                                                <div class="card-body">                                                                          
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Organization Name</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_name" id="erp_sys_org_name" value="<?php echo @$editData['erp_sys_org_name'];?>" autofocus="autofocus" class="form-control" placeholder="Company Name" required=""> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Industry / Business</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <?php $departmentData = $commonFunctions->getData('sys_erp_org_department',' '); ?>
                                                            <select name="erp_sys_org_department" id="erp_sys_org_department" class="select2 form-control" >
                                                                <option value="0">Select Departnemt ( Company )</option>
                                                                <?php foreach ($departmentData as $rw) { ?>
                                                                    <option value="<?php echo $rw['id'];?>" <?php echo (@$editData['erp_sys_org_department'] == $rw['id'])?'selected':'';?> ><?php echo $rw['erp_sys_org_dprtmt_ops']; ?></option>     
                                                                <?php } ?>
                                                            </select> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Number of Empolyees</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="20" name="erp_sys_org_num_emp" id="erp_sys_org_num_emp" value="<?php echo @$editData['erp_sys_org_num_emp'];?>" autofocus="autofocus" class="form-control" placeholder="Number of Empolyees"> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Date of Formation</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="20" name="erp_sys_org_date_formation" id="erp_sys_org_date_formation" value="<?php echo @$editData['erp_sys_org_date_formation'];?>" autofocus="autofocus" class="form-control" placeholder="Date of Formation">  </h5>
                                                        </div>
                                                    </div>                                          
                                                </div>                                            
                                            </div>
                                            <!-- Organization Information Card - End --->
                                            <!-- Organization Address Card - Start --->
                                            <div class="card">
                                                <div class="card-header">
                                                    <div class="row align-items-center">
                                                        <div class="col-11">                      
                                                            <h4 class="card-title text-left">Office Address </h4>                      
                                                        </div><!--end col-->
                                                        <div class="col-1">                      
                                                            <a href="javascript:void(0);"><button type="button" class="text-right btn btn-sm btn-success waves-effect waves-light save_org_data">Save</button></a>              
                                                        </div><!--end col-->                                                       
                                                    </div>  <!--end row-->                                  
                                                </div><!--end card-header-->
                                                <div class="card-body">                                                                          
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Address</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <textarea name="erp_sys_org_address" class="form-control" placeholder="Company Address"><?php echo @$editData['erp_sys_org_address'];?></textarea> </p> </h5>
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Country</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <?php $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 '); ?>
                                                            <select name="erp_sys_org_country" id="erp_sys_org_country" class="select2 form-control" >
                                                                <option value="0">Select Company Country</option>
                                                                <?php foreach ($countryData as $rw) { ?>
                                                                    <option value="<?php echo $rw['rowid'];?>" <?php echo (@$editData['erp_sys_org_country'] == $rw['rowid'])?'selected':'';?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>     
                                                                <?php } ?>
                                                            </select></h5>
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">State / Province</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <?php $stateData = $commonFunctions->getData('sys_erp_adm_countries_states',' WHERE active = 1 '); ?>
                                                            <select name="erp_sys_org_province" id="erp_sys_org_province" class="select2 form-control" >
                                                                <option value="0">Select Company State / Province</option>
                                                                <?php foreach ($stateData as $rw) { ?>
                                                                    <option value="<?php echo $rw['rowid'];?>" <?php echo (@$editData['erp_sys_org_province'] == $rw['rowid'])?'selected':'';?> ><?php echo $rw['label']."(".$rw['region_code'].")"; ?></option>     
                                                                <?php } ?>
                                                            </select> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">City</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_city" id="erp_sys_org_city" value="<?php echo @$editData['erp_sys_org_city'];?>" autofocus="autofocus" class="form-control" placeholder="Company City"> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Zip / Pin / PO Box</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_zip_code" id="erp_sys_org_zip_code" value="<?php echo @$editData['erp_sys_org_zip_code'];?>" autofocus="autofocus" class="form-control" placeholder="Company Zip Code"> </h5>
                                                        </div>
                                                    </div>
                                                                                                        
                                                </div><!--end card-body-->
                                            </div><!--end card-->
                                            <!-- Organization Address Card - End --->
                                        </div> <!--end col--> 
                                        <!-- Contact Information Personal  Card - End --->

                                        <!-- Contact Information Card Official - Start --->
                                        <div class="col-lg-6 col-xl-6">
                                            <div class="card">
                                                <div class="card-header">
                                                    <div class="row align-items-center">
                                                        <div class="col-11">                      
                                                            <h4 class="card-title text-left">Contact Information<label class="col-xl-3 col-lg-3 mb-lg-0 align-self-center">(Organization)</label></h4>                      
                                                        </div><!--end col-->
                                                        <div class="col-1">                      
                                                            <a href="javascript:void(0);"><button type="button" class="text-right btn btn-sm btn-success waves-effect waves-light save_org_data">Save</button></a>              
                                                        </div><!--end col-->                                                       
                                                    </div>  <!--end row-->                                  
                                                </div><!--end card-header-->
                                                <div class="card-body">                                                                          
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Phone </label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_phone_work" id="erp_sys_org_phone_work" value="<?php echo @$editData['erp_sys_org_phone_work'];?>" autofocus="autofocus" class="form-control" placeholder="Work Phone"> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Fax</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_fax" id="erp_sys_org_fax" value="<?php echo @$editData['erp_sys_org_fax'];?>" autofocus="autofocus" class="form-control" placeholder="Work Fax"> </h5>
                                                        </div>
                                                    </div>
                                                     
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Email Address</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_email_work" id="erp_sys_email_work" value="<?php echo @$editData['erp_sys_email_work'];?>" autofocus="autofocus" class="form-control" placeholder="Work eMail"> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Website / URL</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_web" id="erp_sys_org_web" value="<?php echo @$editData['erp_sys_org_web'];?>" autofocus="autofocus" class="form-control" placeholder="Website / URL"> </h5>
                                                        </div>
                                                    </div>
                                                </div><!--end card-body-->
                                            </div><!--end card-->
                                            <!-- Organization Social Media - Start --->
                                            <div class="card">
                                                <div class="card-header">
                                                    <div class="row align-items-center">
                                                        <div class="col-11">                      
                                                            <h4 class="card-title text-left">Social Media </h4>                      
                                                        </div><!--end col-->
                                                        <div class="col-1">                      
                                                            <a href="javascript:void(0);"><button type="button" class="text-right btn btn-sm btn-success waves-effect waves-light save_org_data">Save</button></a>
                                                        </div><!--end col-->                                                       
                                                    </div>  <!--end row-->                                  
                                                </div><!--end card-header-->
                                                <div class="card-body">                                                                          
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Linkedin</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_sm_page_linkedin" id="erp_sys_org_sm_page_linkedin" value="<?php echo @$editData['erp_sys_org_sm_page_linkedin'];?>" autofocus="autofocus" class="form-control" placeholder="linkedIn"> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Twitter</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_sm_page_twitter" id="erp_sys_org_sm_page_twitter" value="<?php echo @$editData['erp_sys_org_sm_page_twitter'];?>" autofocus="autofocus" class="form-control" placeholder="Twitter"> </h5>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">                                         
                                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Facebook</label>
                                                        <div class="col-lg-9 col-xl-8">
                                                            <h5 class="card-title"> <input type="text" maxlength="128" name="erp_sys_org_sm_page_facebook" id="erp_sys_org_sm_page_facebook" value="<?php echo @$editData['erp_sys_org_sm_page_facebook'];?>" autofocus="autofocus" class="form-control" placeholder="Facebook"> </h5>
                                                        </div>
                                                    </div>                                                    
                                                </div><!--end card-body-->
                                            </div><!--end card-->
                                            <!-- Organization Social Media - End --->
                                        </div> <!-- end col -->
                                        <!-- Contact Information Official Card - End --->
                                                                              
                                    </div><!--end row-->
                                </div>

                                <div class="tab-pane fade" id="Branches_Warehouse" role="tabpanel" aria-labelledby="settings_detail_tab">
                                    <div class="row">                        
                                        <div class="col-lg-12">
                                            <div class="card">
                                                <div class="card-header">
                                                    <div class="row align-items-center">
                                                        <div class="col-11">                
                                                            <h4 class="card-title text-left">Branches & Warehouse</h4>                      
                                                        </div><!--end col-->
                                                    </div>
                                                </div>
                                                <style type="text/css">
                                                    tr {cursor: pointer;}
                                                </style>
                                                <div class="card-body">
                                                    <table style="width: 100% !important;" class="table datatable_t table-hover table-striped table-bordered">
                                                        <thead>
                                                            <tr>
                                                                <th class="text-center">SR No.</th>
                                                                <th class="text-center">Warehouse Name</th>
                                                                <th class="text-center">Warehouse Ref</th>
                                                                <th class="text-center">Address</th>
                                                                <th class="text-center">Zip / Pin Code</th>
                                                                <th class="text-center">City</th>
                                                                <th class="text-center">Country</th>
                                                                <!-- <th class="text-center">Status</th> -->
                                                                <!-- <th class="text-center">Action</th> -->
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php $where = ""; 
                                                            $productData = $commonFunctions->getData('invty_wrhus',$where); 
                                                            foreach ($productData as $row) { 
                                                                $i++;?>
                                                                <tr onclick="redirect_1('../../product-services/warehouse/warehouse.php?state=edit&warehouse_id=<?php echo $row['id'];?>')" >
                                                                <th class="text-center text-primary" ><?php echo $row['reference_number'];?></th>
                                                                <th class="text-center text-primary"><?php echo $row['short_name_location'];?></th>
                                                                <th class="text-center"><?php echo $row['description'];?></th>
                                                                <th class="text-center"><?php echo $row['address'];?></th>
                                                                <th class="text-center"><?php echo $row['zip_code'];?></th>
                                                                <th class="text-center"><?php echo $row['city'];?></th>
                                                                <th class="text-center"><?php echo $row['country_id'];?></th>
                                                                <!-- <th>
                                                                    <?php
                                                                        $flag = '';
                                                                        $flag_state = 0;
                                                                        if($row['status'] == 0){
                                                                            $flag = 'checked';
                                                                            $flag_state = 1;
                                                                        }
                                                                        $url = 'warehouse.php?state=list&warehouse_id='.$row['id'].'&flag='.$flag_state;
                                                                        echo '<div class="custom-control custom-switch switch-primary">
                                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                                        </div>';
                                                                    ?>
                                                                </th> -->
                                                            </tr>
                                                            <?php } ?>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div><!--end card--> 
                                        </div> <!--end col--> 
                    
                                    </div> <!-- end row -->
                                    <!-- end page title end breadcrumb -->
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
                <?php endif; ?>
                <?php if($cntB < 1): ?>
                </div>
                <?php endif; ?>
            </div>
        </div> <!-- end col -->
    </div> <!-- end row -->
            
    
<?php require "../../inc/footer.php"; ?>
<script type="text/javascript">
$("#clearbtn").click(function(){
    $("#search").val('');
    $("#searchForm").submit();
});
function redirect_(uri){
    window.location.href = uri;
}
function redirect_1(uri){
    $("<a>").prop({ target: "_blank",href: uri })[0].click();
}
$(".save_org_data").click(function(){
    $.ajax({
        type: 'POST',
        url: "",
        data: $('#editData').serialize()+"&action=ajax_call_1",
        success: function(response) { 
          window.location.href = response;
        }
    });
});
$(".datatable_t").dataTable();

$("#erp_sys_org_country").change(function(){
    var country = $("#erp_sys_org_country option:selected").val();
    $.ajax({
        type: 'POST',
        url: "",
        data: {"country_id":country,"action":"ajax_call"},
        success: function(response) { 
            obj = JSON.parse(response);
            $("#erp_sys_org_province").html("<option value=''>Select State / Province</option>"+obj.option);
        }
    });
})
$(function() {
    $("#erp_sys_org_city").autocomplete({
        source: function(request, response) {
            $.getJSON("", { country_id: $('#erp_sys_org_country option:selected').val(),state_id: $('#erp_sys_org_province option:selected').val(),keyword: request.term,action:"ajax_call1" }, response);
        },
        minLength: 2,
    });
});
</script>