<?php require_once('../auth/auth.php');
require_once('../auth/function.php'); ?>
<?php
$acid = $_GET['acid'];
$acc = mysqli_query($conn, "SELECT accounts.gcatid,accounts.ac_name,accounts.ac_alise,accounts.outlet_id,accounts.ac_number,accounts.ac_email,accounts.divisions,accounts.distr,accounts.polic_sta,accounts.picture,accounts.ac_details,accounts.acsub_type,accounts.ac_area,accounts.em_id,branch.branch_name,branch.branch_code,
account_info.currency,account_info.brithday,account_info.currency,account_info.nid,account_info.gender,account_info.father_name,account_info.mother_name,account_info.g_note,account_info.g_name1,account_info.g_address1,account_info.g_phone1,account_info.g_name2,account_info.g_address2,account_info.g_phone2,account_info.g_note,
c.co_name,c.owner_name,c.co_address,c.co_email,c.co_phone,c.co_logo,business.bid_type FROM `accounts` 
LEFT JOIN account_info ON accounts.acid=account_info.acid
LEFT JOIN branch ON accounts.brid=branch.brid
LEFT JOIN business ON accounts.bid=business.bid


LEFT JOIN company c ON accounts.coid=c.coid 
 WHERE accounts.coid='$coid' AND accounts.bid ='$bid' AND accounts.brid='$brid' AND accounts.acid='$acid' LIMIT 1") or die(mysqli_error($conn));
$ac = mysqli_fetch_assoc($acc);
$gcatid     = $ac['gcatid'];
$ac_area    = $ac['ac_area'];
$em_id      =  $ac['em_id'];
$bid_type   = $ac['bid_type'];

$business_type = mysqli_fetch_assoc(mysqli_query($conn, "SELECT bt_name FROM business_type WHERE  btid='$bid_type' LIMIT 1"))['bt_name'];
$g_name = mysqli_fetch_assoc(mysqli_query($conn, "SELECT ac_g_cat_name FROM ac_sub_g_category WHERE coid='$coid' AND ac_g_catid='$gcatid' LIMIT 1"))['ac_g_cat_name'];
?>

<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
                <div class="card-header" style="padding: 3px 8px;">
                    <h3 class="card-title">Account Profile </h3>
                    <div class="card-tools">
                        <span id="sdf"></span>
                        <button type="button" onclick="pdfMe('#m_receipt');" class="btn btn-tool" title="Download Pdf"><i class="fas fa-download"></i></button>
                        <button type="button" class="btn btn-tool" onclick="printMe('#m_receipt',{'top':'7%','left':'37%'})" title="Print Now"><i class="fas fa-print"></i></button>

                        <button type="button" class="btn btn-tool" data-card-widget="remove" data-dismiss="modal">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>

                <div class="card-body p-1" id="m_receipt" style="overflow:hidden;position: relative;">
                    <input type="hidden" id="vounameset" value="<?php echo $ac['ac_name']; ?> Profile Data ">

                    <?php if ($ac['co_logo'] != "") : ?>
                        <img class="bgimg" src="data:image/gif;base64,<?php echo $ac['co_logo']; ?>">
                    <?php else : ?>
                        <img class="bgimg " src="../../dist/img/a.png">
                    <?php endif; ?> <table style="width: 100%;border: 1px solid #afafaf7a;background:#e9ebed;position: relative;" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th style="width:2%;padding-top:5px;"></th>
                                <th class="text-left" style="width:10%;padding-top:10px;">

                                    <?php if ($ac['co_logo'] != "") : ?>
                                        <img class="profile-user-img img-fluid img-circle" src="data:image/gif;base64,<?php echo $ac['co_logo']; ?>" style="width:80px;height:75px;border-color:Black !important">
                                    <?php else : ?>
                                        <img class="profile-user-img img-fluid img-circle  " src="../../dist/img/a.png" style="width:80px;height:75px;border-color:Black !important">
                                    <?php endif; ?>

                                </th>

                </div>



                <th style="width:10%;padding-top:5px;"></th>
                <th class="text-right" colspan="6" style="padding-top:15px;">
                    <div style="padding-right:5px;">
                        <sss style="font-size:18px;font-weight: 600;"><?php echo $ac['co_name']; ?></sss><br>
                        <sss><?php echo  $ac['owner_name']; ?></sss><br>
                        <sss><?php echo  $ac['co_address']; ?></sss><br>
                        <sss><?php echo  $ac['co_email']; ?></sss> #
                        <sss><?php echo  $ac['co_phone']; ?></sss>
                    </div>
                </th>
                <th style="width:2%;padding-top:5px;">
                    <div style="background-color: #23465a;width: 22px;height:90px;"></div>
                </th>
                </tr>
                <tr>
                    <th style="width:2%;"></th>
                    <th class="text-center" colspan="8">
                        <hr>
                        <sss style="font-size:25px;font-weight: 600;">Accounts Profile <sss>
                                <hr>
                    </th>
                    <th style="width:2%;"></th>
                </tr>
                </thead>
                <tbody>
                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="5" style="font-size: 16px !important;">Name Of Accounts : <?php echo $ac['ac_name']; ?>
                            <p>Display Name : <?php echo $ac['ac_alise']; ?></p>
                        </th>
                        <th colspan="3" style="width:25%;">
                            <?php if ($ac['picture'] != "") : ?>
                                <img class="profile-user-img img-fluid " src="data:image/gif;base64,<?php echo $ac['picture']; ?>" style="width:150px;height:150px;border-color:Black !important;float:right">
                            <?php else : ?>
                                <img class="profile-user-img img-fluid  " src="../../dist/img/no_img.jpg" style="width:120px;height:100px;border-color:Black !important;float:right">
                            <?php endif; ?>

                        </th>
                        <th style="width:2%;"></th>
                    </tr>
                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="3" style="padding-top: 10px;border-bottom: 1px dotted;">Outlet ID : <?php echo $ac['outlet_id']; ?></th>
                        <th colspan="5" style="padding-top: 10px;border-bottom: 1px dotted;">Branch Code: <?php echo $ac['branch_name'] . '/' . $ac['branch_code']; ?></th>

                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th class="text-center" colspan="8">
                            <hr>
                            <sss style="font-size:15px;font-weight: 600;">Personal Information <sss>
                                    <hr>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="5" style="padding-top:10px;border-bottom: 1px dotted;">Mail Address : <?php echo $ac['ac_email']; ?></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;">Phone No : <?php echo  $ac['ac_number']; ?></th>
                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;">Date of Birth : <?php echo $ac['brithday']; ?></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;"> Gender : <?php echo $ac['gender']; ?> </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;">Age :


                            <?php
                            $dob = new DateTime($ac['brithday']);
                            $now = new DateTime();
                            $diff = $now->diff($dob);
                            echo "" . $diff->y . " Years.";
                            // Get the age in years, months and days
                            //  echo "Your current age is " . $diff->y . " years " . $diff->m . " months " . $diff->d . " days.";
                            ?>
                        </th>

                        <th style="width:2%;"></th>
                    </tr>



                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;"> Division : <?php echo $ac['divisions']; ?> </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;">Dristict : <?php echo $ac['distr']; ?></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;">Upazila : <?php echo $ac['polic_sta']; ?></th>
                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="8" style="padding-top:10px;border-bottom: 1px dotted;">Present Address : <?php echo $ac['ac_details']; ?></th>
                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="8" style="padding-top:10px;border-bottom: 1px dotted;"> Permanent Address : <?php echo $ac['ac_details']; ?></th>
                        <th style="width:2%;"></th>
                    </tr>
                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>
                    <tr>
                        <th style="width:2%;"></th>
                        <th class="text-center" colspan="8">
                            <hr>
                            <sss style="font-size:15px;font-weight: 600;">Other Information <sss>
                                    <hr>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>
                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="4" style="padding-top:10px;border-bottom: 1px dotted;"> Father Name : <?php echo $ac['father_name']; ?> </th>
                        <th style="width:1%;"></th>
                        <th colspan="4" style="padding-top:10px;width:25%;border-bottom: 1px dotted;"> Mother Name : <?php echo $ac['mother_name']; ?></th>
                        <th style="width:1%;"></th>

                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="8" style="padding-top:10px;border-bottom: 1px dotted;">Others Info : <?php echo $ac['g_note']; ?></th>
                        <th style="width:2%;"></th>
                    </tr>




                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="5" style="padding-top:10px;border-bottom: 1px dotted;">Nationality :
                            <?php if ($ac['currency'] == 'BDT') {
                                echo "Bangladeshi";
                            } else if ($ac['currency'] == 'MYR') {
                                echo "Malaysian";
                            } else {
                                echo "Unknown Nationality";
                            } ?>
                        </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;">National Id Card : <?php echo $ac['nid']; ?></th>
                        <th style="width:2%;"></th>
                    </tr>
                    
                    

                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>
                    
                     <tr>
                        <th style="width:2%;"></th>
                        <th class="text-center" colspan="8">
                            <hr>
                            <sss style="font-size:15px;font-weight: 600;">Guarantor  Information <sss>
                                    <hr>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>

                      <tr>
                        <th style="width:2%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;"> Guarantor Name(1) : <?php echo $ac['g_name1']; ?></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;"> Address of Guarantor (1) : <?php echo $ac['g_address1']; ?> </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;"> Guarantor Phone (1) :
                                <?php echo $ac['g_phone1']; ?>
                        </th>

                        <th style="width:2%;"></th>
                    </tr>
                    
                       <tr>
                        <th style="width:2%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;"> Guarantor Name(2) : <?php echo $ac['g_name2']; ?></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;"> Address of Guarantor (2) : <?php echo $ac['g_address2']; ?> </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;width:25%;border-bottom: 1px dotted;"> Guarantor Phone (2) :
                                <?php echo $ac['g_phone2']; ?>
                        </th>

                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th class="text-center" colspan="8">
                            <hr>
                            <sss style="font-size:15px;font-weight: 600;">Report Information <sss>
                                    <hr>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="5" style="padding-top:10px;border-bottom: 1px dotted;">Area Name :
                            <?php
                            $road_name = mysqli_fetch_assoc(mysqli_query($conn, "SELECT roid,route_name,road_name FROM route_area WHERE  roid='$ac_area' LIMIT 1 "));
                            echo $road_name['route_name'] . '-' . $road_name['road_name'];

                            ?>
                        </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;">Account Type :
                            <?php if ($ac['acsub_type'] == 'ws') {
                                echo " WholeSaler";
                            } else if ($ac['acsub_type'] == 'retail') {
                                echo " Retail";
                            } else if ($ac['acsub_type'] == 'distri') {
                                echo " Dristributor";
                            } else if ($ac['acsub_type'] == 'emi') {
                                echo " EMI (installment)";
                            } else if ($ac['acsub_type'] == 'B2B') {
                                echo " B2B (sales)";
                            } ?>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>


                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="5" style="padding-top:10px;border-bottom: 1px dotted;">Under Report :
                            <?php
                            @$emm = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM user  WHERE us_coid='$coid' AND us_bid='$bid' AND us_brid='$brid' AND uid='$em_id' LIMIT 1 "));
                            @$grtus_em_id = $emm['us_em_id'];
                            echo  @$em_name = mysqli_fetch_assoc(mysqli_query($conn, "SELECT em_acname FROM em_employee WHERE  em_id='$grtus_em_id' LIMIT 1 "))['em_acname'];
                            //echo $emm['username'] . '-' . $emm['username'];
                            ?>
                        </th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="padding-top:10px;border-bottom: 1px dotted;">Business Type :
                            <?php echo $business_type; ?>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>
                    
                     <tr>
                        <th style="width:2%;"></th>
                        <th class="text-center" colspan="8">
                            <hr>
                            <sss style="font-size:15px;font-weight: 600;">Genarel Note Information <sss>
                                    <hr>
                        </th>
                        <th style="width:2%;"></th>
                    </tr>
                    
                    <tr>
                              <th style="width:2%;"></th>
                        <th colspan="5" style="padding-top:10px;border-bottom: 1px dotted;"> Genarel Note: <?php echo $ac['g_note']; ?></th>
                    </tr>
                    
                    

                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>

                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>

                    <!--<tr>-->
                    <!--    <th colspan="10">&nbsp;</th>-->
                    <!--</tr>-->

                    <!--<tr>-->
                    <!--    <th colspan="10">&nbsp;</th>-->
                    <!--</tr>-->

                    <!--<tr>-->
                    <!--    <th colspan="10">&nbsp;</th>-->
                    <!--</tr>-->
                    <!--<tr>-->
                    <!--    <th colspan="10">&nbsp;</th>-->
                    <!--</tr>-->

                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>

                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>


                    <tr>
                        <th class="mt-2" colspan="10">&nbsp;</th>
                    </tr>


                    <tr>
                        <th class="mt-3" colspan="10">&nbsp;</th>
                    </tr>



                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="2" style="border-bottom: 1px dotted;"></th>

                        <th style="width:1%;"></th>
                        <th class="text-center" style="border-bottom: 1px dotted;"></th>
                        <th></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" style="border-bottom: 1px dotted;"></th>
                        <th style="width:2%;"></th>
                    </tr>
                    <tr>
                        <th style="width:2%;"></th>
                        <th colspan="2" class="text-center">Account signature </th>

                        <th style="width:1%;"></th>
                        <th class="text-center">Manager signature</th>
                        <th></th>
                        <th style="width:1%;"></th>
                        <th colspan="2" class="text-center">Authorized signature</th>
                        <th style="width:2%;"></th>
                    </tr>

                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>

                </tbody>
                <tfoot>
                    <tr>
                        <th colspan="10">&nbsp;</th>
                    </tr>
                    <tr>
                        <th class="text-center" colspan="10" style="padding: 5px 15px;background:#23465a;color: #fff;">
                            <dt><a href="https://welldiv.com" target="_blank" style="color:#fff;"> <?php echo $welldiv  ?></a></dt>
                        </th>

                    </tr>
                </tfoot>
                </table>
            </div>
        </div>
    </div>
    </div>
</section>

