You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							327 lines
						
					
					
						
							14 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							327 lines
						
					
					
						
							14 KiB
						
					
					
				| <?php | |
| 
 | |
|     session_start(); | |
| 
 | |
|     @include 'cgi-bin/conn.conn'; | |
|     @include 'cgi-bin/functions.inc'; | |
|     @include 'cgi-bin/params.inc'; | |
| 
 | |
|     $conn=@mysqli_connect($DATAhst,$DATAusr,$DATApwd,$DATAdtb)or die("CONNECTION ERROR"); | |
|     mysqli_set_charset($conn, "utf8"); | |
| 
 | |
| ?> | |
|  | |
|  | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
|  | |
|     <title>COZe</title> | |
|  | |
|     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
|     <meta name="description" content="COZe"> | |
|     <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> | |
|  | |
|     <base href="<?php echo $BASE_URL;?>/"> | |
|     <?php | |
|     @include 'cssvendors.php'; | |
|     ?> | |
|  | |
| </head> | |
| <body> | |
|  | |
|     <div id="MainContent" class="container"> | |
|         <form method="post" enctype="multipart/form-data" class="add_message_form"> | |
|  | |
|         <?php | |
|  | |
|             if($_POST['title']) { | |
|                 $image=0; | |
|                 $text = explode("%break%", $_POST['text']); | |
|                 if(is_uploaded_file($_FILES['image']['tmp_name'])){ | |
|                     $image = date("YmdHis"); | |
|                     $imagePath = "/images/upload/$image.jpg"; | |
|                     save_photo($_FILES['image']['tmp_name'],"images/upload/",$image); | |
|                 } | |
|  | |
|                 if($_POST['del-img']){ | |
|                     $imagePath=""; | |
|                 } | |
|  | |
|                 $actions = array(); | |
|  | |
|                 if($_POST['action_title'][0] != ""){ | |
|                     foreach ($_POST['action_title'] as $index => $message) { | |
|                         $action_title = $_POST['action_title'][$index]; | |
|                         $action_description = $_POST['action_description'][$index]; | |
|                         $action_message = $_POST['action_message'][$index]; | |
|                         $action_id = $_POST['action_id'][$index]; | |
|                         if($action_id == 0){ | |
|                             mysqli_query($conn, "INSERT INTO actions VALUES(null, '".$action_title."', '".$action_description."',".$action_message.")"); | |
|                             $actions[$index] = mysqli_insert_id($conn); | |
|                         }else{ | |
|                             mysqli_query($conn, "UPDATE actions SET label='".$action_title."', description='".$action_description."', mid=".$action_message." WHERE id=$action_id"); | |
|                             $actions[$index] = $action_id; | |
|                         } | |
|                     } | |
|                 } | |
|  | |
|                 $q = mysqli_query($conn, "UPDATE messages SET sid='".$_POST['session']."', title='".convert($_POST['title'])."', | |
|                                             short_text='".convert_mce($text[0])."', long_text='".convert_mce($text[1])."', | |
|                                             image='$imagePath', actions='".implode(",", $actions)."', | |
|                                             timer='".$_POST['hours'].":".$_POST['minutes'].":".$_POST['seconds']."', | |
|                                             progress=".$_POST['progress']." WHERE id=".$_POST['id']); | |
|  | |
|  | |
|                 echo "<script>parent.window.location=parent.window.location</script>"; | |
|  | |
|             } else { | |
|  | |
|                 $q = mysqli_query($conn, "SELECT * FROM messages WHERE id=".$_GET['id'].""); | |
|                 $r = mysqli_fetch_array($q); | |
|         ?> | |
|  | |
|             <div class="row"> | |
|                 <div class="col-12"> | |
|                     <span class="font-12 text-grey">Session</span> | |
|                     <div class="row"> | |
|                         <div class="col"> | |
|                             <select name="session"> | |
|                             <?php | |
|                                 $qs = mysqli_query($conn, "SELECT * FROM `session` ORDER BY name"); | |
|  | |
|                                 while($rs = mysqli_fetch_array($qs)){ | |
|                                     echo "<option value=\"".$rs['id']."\" "; | |
|                                     if($r['sid'] == $rs['id']){echo "selected";} | |
|                                     echo ">".$rs['name']."</option>\n"; | |
|                                 } | |
|                             ?> | |
|                             </select> | |
|                         </div> | |
|                     </div> | |
|                 </div> | |
|                 <div class="col-12"> | |
|                     <span class="font-12 text-grey">Message title</span> | |
|                     <input type="text" name="title" value="<?= $r['title'];?>"> | |
|                     <input type="hidden" name="id" value="<?= $_GET['id'];?>"> | |
|                 </div> | |
|                 <div class="col-12"> | |
|                     <span class="font-12 text-grey">Message text</span> | |
|                     <textarea class="mce" name="text"><?= $r['short_text']."%break%".$r['long_text'];?></textarea> | |
|                 </div> | |
|                 <div class="col-10 mt-3"> | |
|                     <span class="font-12 text-grey">Image<br></span> | |
|                     <input type="file" name="image"> | |
|                 </div> | |
|                 <div class="col-1 mt-3"> | |
|                     <?php | |
|                         if($r['image']){ | |
|                             echo "<img src=\"".$r['image']."\" width=\"100%\">"; | |
|                         } | |
|                     ?> | |
|                 </div> | |
|                 <div class="col-1"> | |
|                     <?php | |
|                         if($r['image']){ | |
|                             echo "<input type=\"checkbox\" name=\"del-img\" class=\"full-middle\" value=\"".$r['id']."\">"; | |
|                         } | |
|                     ?> | |
|                 </div> | |
|  | |
|                 <div class="col-12"> | |
|                     <span class="font-12 text-grey">Actions</span> | |
|                     <div class="row item"> | |
|                             <div class="col-3 font-10 text-grey"> | |
|                                 Label | |
|                             </div> | |
|                             <div class="col-4 font-10 text-grey"> | |
|                                 Description | |
|                             </div> | |
|                             <div class="col-4 font-10 text-grey"> | |
|                                 Link to | |
|                             </div> | |
|                             <div class="col-1"></div> | |
|                         </div> | |
|                     </div> | |
|                     <div class="actions col-12"> | |
|                         <?php | |
|                             if($r['actions']){ | |
|                                 $cnt=0; | |
|                                 $qpa = mysqli_query($conn, "SELECT * FROM actions WHERE id IN(".$r['actions'].")"); | |
|                                 while($rpa = mysqli_fetch_array($qpa)){ | |
|                                 $cnt++; | |
|                             ?> | |
|  | |
|                                 <div class="row item"> | |
|                                     <div class="col-3"> | |
|                                         <input type="hidden" name="action_id[]" value="<?= $rpa['id'];?>"> | |
|                                         <input type="text" name="action_title[]" value="<?= $rpa['label'];?>"> | |
|                                     </div> | |
|                                     <div class="col-4"> | |
|                                         <input type="text" name="action_description[]" value="<?= $rpa['description'];?>"> | |
|                                     </div> | |
|                                     <div class="col-4"> | |
|                                         <select name="action_message[]"> | |
|                                         <?php | |
|                                         $qm = mysqli_query($conn, "SELECT * FROM messages ORDER BY title"); | |
|                                             while($rm = mysqli_fetch_array($qm)){ | |
|                                                 echo "<option value=\"".$rm['id']."\" "; | |
|                                                 if($rpa['mid'] == $rm['id']){echo "selected";} | |
|                                                 echo ">".$rm['title']."</option>\n"; | |
|                                             } | |
|                                         ?> | |
|                                         </select> | |
|                                     </div> | |
|                                     <div class="col-1"> | |
|                                         <button class="button grey del-row mx-0" <?php if($cnt==1){echo "disabled";}?>><i class="fa fa-minus"></i></button> | |
|                                     </div> | |
|                                 </div> | |
|  | |
|                             <?php | |
|                                 } | |
|                             }else{ | |
|                         ?> | |
|                         <div class="row item"> | |
|                             <div class="col-3"> | |
|                                 <input type="hidden" name="action_id[]" value="0"> | |
|                                 <input type="text" name="action_title[]" placeholder="No action"> | |
|                             </div> | |
|                             <div class="col-4"> | |
|                                 <input type="text" name="action_description[]"> | |
|                             </div> | |
|                             <div class="col-4"> | |
|                                 <select name="action_message[]"> | |
|                                 <?php | |
|                                  $qm = mysqli_query($conn, "SELECT * FROM messages ORDER BY title"); | |
|                                     while($rm = mysqli_fetch_array($qm)){ | |
|                                         echo "<option value=\"".$rm['id']."\">".$rm['title']."</option>\n"; | |
|                                     } | |
|                                 ?> | |
|                                 </select> | |
|                             </div> | |
|                             <div class="col-1"> | |
|                                 <button class="button grey del-row mx-0" disabled><i class="fa fa-minus"></i></button> | |
|                             </div> | |
|                         </div> | |
|                         <?php | |
|                             } | |
|                         ?> | |
|                     </div> | |
|                 </div> | |
|                 <div class="col-12"> | |
|                     <div class="row"> | |
|                         <div class="col-12 text-left p-0"> | |
|                             <button class="button grey add-row mx-0"><i class="fa fa-plus"></i></button> | |
|                         </div> | |
|                     </div> | |
|                 </div> | |
|  | |
|  | |
|  | |
|                 <div class="col-12 px-0"> | |
|                     <hr> | |
|                     <span class="font-12 text-grey">Schedule</span> | |
|                     <div class="row"> | |
|                         <div class="col"> | |
|                             <button class="button <?php if($r['timer']=='00:00:00' && $r['progress']==0){echo "discard";}else{echo "grey";}?> big full mx-0" id="btn_none">Not scheduled</button> | |
|                         </div> | |
|                         <div class="col"> | |
|                             <button class="button <?php if($r['progress']!=0){echo "discard";}else{echo "grey";}?> big full mx-0" id="btn_progress">Schedule</button> | |
|                         </div> | |
|                         <div class="col"> | |
|                             <button class="button <?php if($r['timer']!='00:00:00' && $r['progress']==0){echo "discard";}else{echo "grey";}?> big full mx-0" id="btn_timer">Start after</button> | |
|                         </div> | |
|                     </div> | |
|                 </div> | |
|  | |
|  | |
|                 <div class="col-6 mx-auto my-5 <?php if($r['timer']=='00:00:00'){echo "d-none";}?>" id="div_timer"> | |
|                     <span class="font-12 text-grey">Start after (HH:MM:SS)</span> | |
|                     <div class="row"> | |
|                         <div class="col"> | |
|                             <select name="hours" class="text-center hours"> | |
|                             <?php | |
|                                 $timer = explode(':',$r['timer']); | |
|                                 for($i=0;$i<24;$i++){ | |
|                                     echo "<option value=\"".sprintf("%02d", $i)."\" "; | |
|                                     if($timer[0]==sprintf("%02d", $i)){echo "selected";} | |
|                                     echo ">".sprintf("%02d", $i)."</option>\n"; | |
|                                 } | |
|                             ?> | |
|                             </select> | |
|                         </div> | |
|                         <div class="col hseparator"> | |
|                             <select name="minutes" class="text-center minutes"> | |
|                             <?php | |
|                                 for($i=0;$i<60;$i++){ | |
|                                     echo "<option value=\"".sprintf("%02d", $i)."\" "; | |
|                                     if($timer[1]==sprintf("%02d", $i)){echo "selected";} | |
|                                     echo ">".sprintf("%02d", $i)."</option>\n"; | |
|                                 } | |
|                             ?> | |
|                             </select> | |
|                         </div> | |
|                         <div class="col hseparator"> | |
|                             <select name="seconds" class="text-center seconds"> | |
|                             <?php | |
|                                 for($i=0;$i<60;$i++){ | |
|                                     echo "<option value=\"".sprintf("%02d", $i)."\" "; | |
|                                     if($timer[2]==sprintf("%02d", $i)){echo "selected";} | |
|                                     echo ">".sprintf("%02d", $i)."</option>\n"; | |
|                                 } | |
|                             ?> | |
|                             </select> | |
|                         </div> | |
|                     </div> | |
|                 </div> | |
|  | |
|                 <div class="col-6 mx-auto my-5 <?php if($r['progress']==0){echo "d-none";}?>" id="div_progress"> | |
|                     <span class="font-12 text-grey">Progress</span> | |
|                     <div class="row"> | |
|                         <div class="col"> | |
|                             <select name="progress" class="text-center schedule"> | |
|                             <option value="0" style="display: none; opacity:0">0</option> | |
|                             <?php | |
|                                 for($i=1;$i<60;$i++){ | |
|                                     echo "<option value=\"$i\" "; | |
|                                     if($r['progress']!=0 && $r['progress']==$i){echo "selected";} | |
|                                     echo ">$i</option>\n"; | |
|                                 } | |
|                             ?> | |
|                             </select> | |
|                         </div> | |
|                     </div> | |
|                 </div> | |
|  | |
|                 <div class="col-6 mx-auto my-5 text-center <?php if($r['timer']!='00:00:00' || $r['progress']!=0){echo "d-none";}?>" id="div_none"> | |
|                     <span class="font-12 text-grey">Not scheduled</span> | |
|                 </div> | |
|  | |
|  | |
|  | |
|                 <div class="col-12 text-center p4 px-0"> | |
|                     <button type="submit" class="button big full confirm mx-0">Update message</button> | |
|                 </div> | |
|             </div> | |
|  | |
|         <?php | |
|             } | |
|         ?> | |
|  | |
|         </form> | |
|     </div> | |
|  | |
|     <?php | |
|         @include 'jsvendors.php'; | |
|         @include 'scripts/'.$getQ[0].'.php'; | |
|     ?> | |
|  | |
|  | |
| </body> | |
| </html> | |
|  | |
|  | |
|  | |
| <?php | |
| mysqli_close($conn); | |
| ?>
 |