<?php
/**
 * Data Grid Page Example
 *
 * PHP version 7.3
 *
 * @package        SMS
 * @version        Release 1.0.0
 * @create_by      Mohammad aljaouni
 * @create_date    18-08-2020
 * @edited_by
 * @last_edit_date
 * @todo           Nothing
 */
ob_start();
session_start();
$chain = "AWdrh78y892Djk*^523*%$#ghgHGHia&%$*)AsfdsLJnLaad";
$dataTable=true;
include("validateLogin.php");
include("includeInformation.php");
include("header.php");
$resultMsg=array();
$resultMsg[1]="عفوا ... اسم المستخدم أو كلمة المرور غير صحيح";  
$resultMsg[3]="الرصيد غير كافي لارسال الرسالة";
$resultMsg[5]="لطفا ادخل كود التفعيل";
$resultMsg[10]="تمت ارسال هذه المجموعه بنجاح";
$resultMsg[11]="رصيدك 0 , الرجاء إعادة التعبئة حتى تتمكن من إرسال الرسائل";
$resultMsg[12]="الرقم غير مفعل ، يمكنك تفعيلة  من صفحة الأرسال";
$resultMsg[13] = "إسم المرسل غير مقبول";
$resultMsg[14]="غير مصرح لك بالإرسال بإستخدام هذا المرسل ";
$resultMsg[15]=" الأرقام المرسل لها غير موجوده";
$resultMsg[16]="إسم المرسل فارغ، أو غير صحيح";
$resultMsg[17]="نص الرسالة غير متوفر أو غير مشفر بشكل صحيح";



?>
<!-- start main-content -->
<div class="main-content">
    <!-- Start Page-content -->
    <div class="page-content">
        <!-- Page-Title -->
        <div class="page-title-box">
            <div class="container-fluid">
                <div class="row align-items-center">
                    <?php echo breadcrumbs(basename($_SERVER['PHP_SELF']));?>
                </div>
            </div>
        </div>
        <!-- end page title end breadcrumb -->
        <?php
		$querySendMsgTemp = "select * from msg_send_temp WHERE userId!='1' AND `counter`>='20' order by numbers";
     	$resultSendMsgTemp = mysqli_query($conn, $querySendMsgTemp);
    	$numSendMsgTemp = mysqli_num_rows($resultSendMsgTemp);
		?>
        <div class="page-content-wrapper">
            <div class="container-fluid">
                <div class="row justify-content-center align-items-center table-hover">
                    <div class="col-12">
                        <div class="card">
                        <?php
						if(!empty($_GET['sendErrorMsg'])) {
						if($_GET['sendErrorMsg'] == 2)
							echo result(221);
					}
					if(!empty($_GET["res"]))
						echo result($_GET["res"]);
					?>
                        <form name="formList" action="tempMsg.php" method="post">
                            <div class="card-body">
                               <div class="table-responsive">
                                   <table class="table table-bordered">
                                      <thead>
                                         <tr>
                                            <th scope="col"><?php echo $queueListLBL["sender"];?></th>
                                           	<th scope="col"><?php echo $queueListLBL["msg"];?></th>
                                            <th scope="col"><?php echo $queueListLBL["number"];?></th>
                                            <th scope="col"><?php echo $queueListLBL["date"];?></th>
                                            <th scope="col"><?php echo $queueListLBL["counter"];?></th>
                                            <th scope="col"><?php echo $queueListLBL["sendCase"];?></th>
                                            <th scope="col" align="center" style="text-align:center"><?php echo $dataGtidLBL["operations"];?></th>
                                         </tr>
                                      </thead>
                                      <tbody>
                                      <?php
                                        if(!empty($numSendMsgTemp)) {
                                            for($i=0;$i<$numSendMsgTemp;$i++){
												$rowSendMsgTemp = mysqli_fetch_array($resultSendMsgTemp);
												$resultSendMsgTempCheck = mysqli_query($conn, "select id from msg_send_temp where numbers='".$rowSendMsgTemp["numbers"]."' and msg='".$rowSendMsgTemp["msg"]."' and userSender='".$rowSendMsgTemp["userSender"]."'");
												$numSendMsgTempCheck = mysqli_num_rows($resultSendMsgTempCheck);
											if($numSendMsgTempCheck>1){		
                                        ?>
                                        
                                         <tr>
                                            <td style="color:red"><?php echo $rowSendMsgTemp["userSender"]?></td>
                                            <td style="color:red"><?php echo stripcslashes($rowSendMsgTemp["msg"])?></td>
                                            <td style="color:red" align="center"><textArea rows="3" cols="20" name=numbers<?php echo $row[0]?> style="background-color:#fff;border:0;overflow:auto;color:red;border-top-style:solid;border-top-width:1;border-bottom-style:solid;border-bottom-width:1;"><?php echo $rowSendMsgTemp["numbers"]?></textArea></td>
                                            <td  align="center" style="color:red"><?php echo date("A h:i Y.m.d", 0+$row[4]);?></td>
                                            <td style="color:red" align="center"><?php echo $rowSendMsgTemp["counter"]?></td>
                                            <td style="color:red" align="center"><?php if(empty($rowSendMsgTemp["sendCase"])){echo " ";} else  {echo $resultMsg[$rowSendMsgTemp["sendCase"]];};?></td>
                                            <td  align="center"><a href=queueDelete.php?id=<?php echo $rowSendMsgTemp["id"]?>&userId=<?php echo $rowSendMsgTemp["userId"]?>><i class="fas fa-2x fa-trash" title="<?php echo $button["delete"];?>"></i></a></td>
                                         </tr>
                                         <?php
											}else{
										?>
                                        <tr>
                                            <td ><?php echo $rowSendMsgTemp["userSender"]?></td>
                                            <td ><?php echo stripcslashes($rowSendMsgTemp["msg"])?></td>
                                            <td style="color:red" align="center"><textArea rows="3" cols="20" name=numbers<?php echo $row[0]?> style="background-color:#fff;?>;border:0;overflow:auto;color:red;border-top-style:solid;border-top-width:1;border-bottom-style:solid;border-bottom-width:1;"><?php echo $rowSendMsgTemp["numbers"]?></textArea></td>
                                            <td  align="center" style="color:red"><?php echo date("A h:i Y.m.d", 0+$row[4]);?></td>
                                            <td  align="center"><?php echo $rowSendMsgTemp["counter"]?></td>
                                            <td  align="center"><?php if(empty($rowSendMsgTemp["sendCase"])){echo " ";} else  {echo $resultMsg[$rowSendMsgTemp["sendCase"]];};?></td>
                                            <td  align="center"><a href=queueDelete.php?id=<?php echo $rowSendMsgTemp["id"]?>&userId=<?php echo $rowSendMsgTemp["userId"]?>><i class="fas fa-2x fa-trash" title="<?php echo $button["delete"];?>"></i></a></td>
                                         </tr>
                                        <?php
											}
                                                }
                                            } else {
                                        ?>
                                        <tr>
                                            <td colspan="12" style="text-align:center;font-weight:bold"><?php echo $msgBoxListLBL["noData"];?></td>
                                         </tr>
                                        <?php
                                            }
                                        ?>
                                      </tbody>
                                   </table>
                               </div>
                            </div>
                            </form>
                        </div>
                    </div> <!-- end col -->
                </div>
                <!-- end row -->
                </div>
                <!-- end container-fluid -->
            </div>
            <!-- end page-content-wrapper -->
        </div>
        <!-- End Page-content -->
    </div>
   
    <!-- end main content -->
<?php
include("footer.php");
ob_end_flush();
?>
